18#ifndef INCLUDE_NLOHMANN_JSON_HPP_
19#define INCLUDE_NLOHMANN_JSON_HPP_
24#include <initializer_list>
60#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
61 #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH)
62 #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2
63 #warning "Already included a different version of the library!"
68#define NLOHMANN_JSON_VERSION_MAJOR 3
69#define NLOHMANN_JSON_VERSION_MINOR 11
70#define NLOHMANN_JSON_VERSION_PATCH 2
72#ifndef JSON_DIAGNOSTICS
73 #define JSON_DIAGNOSTICS 0
76#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
77 #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0
81 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag
83 #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS
86#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
87 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp
89 #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON
92#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION
93 #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0
97#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b
98#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \
99 NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b)
101#define NLOHMANN_JSON_ABI_TAGS \
102 NLOHMANN_JSON_ABI_TAGS_CONCAT( \
103 NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \
104 NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON)
107#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \
108 _v ## major ## _ ## minor ## _ ## patch
109#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \
110 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch)
112#if NLOHMANN_JSON_NAMESPACE_NO_VERSION
113#define NLOHMANN_JSON_NAMESPACE_VERSION
115#define NLOHMANN_JSON_NAMESPACE_VERSION \
116 NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \
117 NLOHMANN_JSON_VERSION_MINOR, \
118 NLOHMANN_JSON_VERSION_PATCH)
122#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b
123#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \
124 NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b)
126#ifndef NLOHMANN_JSON_NAMESPACE
127#define NLOHMANN_JSON_NAMESPACE \
128 nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \
129 NLOHMANN_JSON_ABI_TAGS, \
130 NLOHMANN_JSON_NAMESPACE_VERSION)
133#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN
134#define NLOHMANN_JSON_NAMESPACE_BEGIN \
137 inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \
138 NLOHMANN_JSON_ABI_TAGS, \
139 NLOHMANN_JSON_NAMESPACE_VERSION) \
143#ifndef NLOHMANN_JSON_NAMESPACE_END
144#define NLOHMANN_JSON_NAMESPACE_END \
162#include <forward_list>
167#include <type_traits>
168#include <unordered_map>
231#include <type_traits>
251template<
typename ...Ts>
struct make_void
255template<
typename ...Ts>
using void_t =
typename make_void<Ts...>::type;
276template<
class Default,
278 template<
class...>
class Op,
286template<
class Default,
template<
class...>
class Op,
class... Args>
293template<
template<
class...>
class Op,
class... Args>
296template<
template<
class...>
class Op,
class... Args>
299template<
template<
class...>
class Op,
class... Args>
300using detected_t =
typename detector<nonesuch, void, Op, Args...>::type;
302template<
class Default,
template<
class...>
class Op,
class... Args>
303using detected_or = detector<Default, void, Op, Args...>;
305template<
class Default,
template<
class...>
class Op,
class... Args>
308template<
class Expected,
template<
class...>
class Op,
class... Args>
311template<
class To,
template<
class...>
class Op,
class... Args>
313 std::is_convertible<
detected_t<Op, Args...>, To>;
334#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15)
335#if defined(JSON_HEDLEY_VERSION)
336 #undef JSON_HEDLEY_VERSION
338#define JSON_HEDLEY_VERSION 15
340#if defined(JSON_HEDLEY_STRINGIFY_EX)
341 #undef JSON_HEDLEY_STRINGIFY_EX
343#define JSON_HEDLEY_STRINGIFY_EX(x) #x
345#if defined(JSON_HEDLEY_STRINGIFY)
346 #undef JSON_HEDLEY_STRINGIFY
348#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x)
350#if defined(JSON_HEDLEY_CONCAT_EX)
351 #undef JSON_HEDLEY_CONCAT_EX
353#define JSON_HEDLEY_CONCAT_EX(a,b) a##b
355#if defined(JSON_HEDLEY_CONCAT)
356 #undef JSON_HEDLEY_CONCAT
358#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b)
360#if defined(JSON_HEDLEY_CONCAT3_EX)
361 #undef JSON_HEDLEY_CONCAT3_EX
363#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c
365#if defined(JSON_HEDLEY_CONCAT3)
366 #undef JSON_HEDLEY_CONCAT3
368#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c)
370#if defined(JSON_HEDLEY_VERSION_ENCODE)
371 #undef JSON_HEDLEY_VERSION_ENCODE
373#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision))
375#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR)
376 #undef JSON_HEDLEY_VERSION_DECODE_MAJOR
378#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
380#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR)
381 #undef JSON_HEDLEY_VERSION_DECODE_MINOR
383#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
385#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION)
386 #undef JSON_HEDLEY_VERSION_DECODE_REVISION
388#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
390#if defined(JSON_HEDLEY_GNUC_VERSION)
391 #undef JSON_HEDLEY_GNUC_VERSION
393#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
394 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
395#elif defined(__GNUC__)
396 #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
399#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK)
400 #undef JSON_HEDLEY_GNUC_VERSION_CHECK
402#if defined(JSON_HEDLEY_GNUC_VERSION)
403 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
405 #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0)
408#if defined(JSON_HEDLEY_MSVC_VERSION)
409 #undef JSON_HEDLEY_MSVC_VERSION
411#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL)
412 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100)
413#elif defined(_MSC_FULL_VER) && !defined(__ICL)
414 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10)
415#elif defined(_MSC_VER) && !defined(__ICL)
416 #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
419#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK)
420 #undef JSON_HEDLEY_MSVC_VERSION_CHECK
422#if !defined(JSON_HEDLEY_MSVC_VERSION)
423 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0)
424#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
425 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
426#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
427 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
429 #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor)))
432#if defined(JSON_HEDLEY_INTEL_VERSION)
433 #undef JSON_HEDLEY_INTEL_VERSION
435#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL)
436 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE)
437#elif defined(__INTEL_COMPILER) && !defined(__ICL)
438 #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
441#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK)
442 #undef JSON_HEDLEY_INTEL_VERSION_CHECK
444#if defined(JSON_HEDLEY_INTEL_VERSION)
445 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
447 #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0)
450#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
451 #undef JSON_HEDLEY_INTEL_CL_VERSION
453#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL)
454 #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0)
457#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK)
458 #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
460#if defined(JSON_HEDLEY_INTEL_CL_VERSION)
461 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
463 #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0)
466#if defined(JSON_HEDLEY_PGI_VERSION)
467 #undef JSON_HEDLEY_PGI_VERSION
469#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
470 #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
473#if defined(JSON_HEDLEY_PGI_VERSION_CHECK)
474 #undef JSON_HEDLEY_PGI_VERSION_CHECK
476#if defined(JSON_HEDLEY_PGI_VERSION)
477 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
479 #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0)
482#if defined(JSON_HEDLEY_SUNPRO_VERSION)
483 #undef JSON_HEDLEY_SUNPRO_VERSION
485#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
486 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10)
487#elif defined(__SUNPRO_C)
488 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf)
489#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
490 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10)
491#elif defined(__SUNPRO_CC)
492 #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf)
495#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK)
496 #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
498#if defined(JSON_HEDLEY_SUNPRO_VERSION)
499 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
501 #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0)
504#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
505 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION
507#if defined(__EMSCRIPTEN__)
508 #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__)
511#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK)
512 #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
514#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION)
515 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
517 #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0)
520#if defined(JSON_HEDLEY_ARM_VERSION)
521 #undef JSON_HEDLEY_ARM_VERSION
523#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
524 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100)
525#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
526 #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100)
529#if defined(JSON_HEDLEY_ARM_VERSION_CHECK)
530 #undef JSON_HEDLEY_ARM_VERSION_CHECK
532#if defined(JSON_HEDLEY_ARM_VERSION)
533 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
535 #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0)
538#if defined(JSON_HEDLEY_IBM_VERSION)
539 #undef JSON_HEDLEY_IBM_VERSION
541#if defined(__ibmxl__)
542 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__)
543#elif defined(__xlC__) && defined(__xlC_ver__)
544 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
545#elif defined(__xlC__)
546 #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
549#if defined(JSON_HEDLEY_IBM_VERSION_CHECK)
550 #undef JSON_HEDLEY_IBM_VERSION_CHECK
552#if defined(JSON_HEDLEY_IBM_VERSION)
553 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
555 #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0)
558#if defined(JSON_HEDLEY_TI_VERSION)
559 #undef JSON_HEDLEY_TI_VERSION
562 defined(__TI_COMPILER_VERSION__) && \
564 defined(__TMS470__) || defined(__TI_ARM__) || \
565 defined(__MSP430__) || \
566 defined(__TMS320C2000__) \
568#if (__TI_COMPILER_VERSION__ >= 16000000)
569 #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
573#if defined(JSON_HEDLEY_TI_VERSION_CHECK)
574 #undef JSON_HEDLEY_TI_VERSION_CHECK
576#if defined(JSON_HEDLEY_TI_VERSION)
577 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
579 #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0)
582#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
583 #undef JSON_HEDLEY_TI_CL2000_VERSION
585#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
586 #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
589#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK)
590 #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
592#if defined(JSON_HEDLEY_TI_CL2000_VERSION)
593 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
595 #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0)
598#if defined(JSON_HEDLEY_TI_CL430_VERSION)
599 #undef JSON_HEDLEY_TI_CL430_VERSION
601#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
602 #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
605#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK)
606 #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
608#if defined(JSON_HEDLEY_TI_CL430_VERSION)
609 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
611 #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0)
614#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
615 #undef JSON_HEDLEY_TI_ARMCL_VERSION
617#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__))
618 #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
621#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK)
622 #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
624#if defined(JSON_HEDLEY_TI_ARMCL_VERSION)
625 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
627 #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0)
630#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
631 #undef JSON_HEDLEY_TI_CL6X_VERSION
633#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
634 #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
637#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK)
638 #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
640#if defined(JSON_HEDLEY_TI_CL6X_VERSION)
641 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
643 #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0)
646#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
647 #undef JSON_HEDLEY_TI_CL7X_VERSION
649#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
650 #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
653#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK)
654 #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
656#if defined(JSON_HEDLEY_TI_CL7X_VERSION)
657 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
659 #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0)
662#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
663 #undef JSON_HEDLEY_TI_CLPRU_VERSION
665#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
666 #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000))
669#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK)
670 #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
672#if defined(JSON_HEDLEY_TI_CLPRU_VERSION)
673 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
675 #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0)
678#if defined(JSON_HEDLEY_CRAY_VERSION)
679 #undef JSON_HEDLEY_CRAY_VERSION
682 #if defined(_RELEASE_PATCHLEVEL)
683 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL)
685 #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
689#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK)
690 #undef JSON_HEDLEY_CRAY_VERSION_CHECK
692#if defined(JSON_HEDLEY_CRAY_VERSION)
693 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
695 #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0)
698#if defined(JSON_HEDLEY_IAR_VERSION)
699 #undef JSON_HEDLEY_IAR_VERSION
701#if defined(__IAR_SYSTEMS_ICC__)
703 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000))
705 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0)
709#if defined(JSON_HEDLEY_IAR_VERSION_CHECK)
710 #undef JSON_HEDLEY_IAR_VERSION_CHECK
712#if defined(JSON_HEDLEY_IAR_VERSION)
713 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
715 #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0)
718#if defined(JSON_HEDLEY_TINYC_VERSION)
719 #undef JSON_HEDLEY_TINYC_VERSION
721#if defined(__TINYC__)
722 #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
725#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK)
726 #undef JSON_HEDLEY_TINYC_VERSION_CHECK
728#if defined(JSON_HEDLEY_TINYC_VERSION)
729 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
731 #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0)
734#if defined(JSON_HEDLEY_DMC_VERSION)
735 #undef JSON_HEDLEY_DMC_VERSION
738 #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
741#if defined(JSON_HEDLEY_DMC_VERSION_CHECK)
742 #undef JSON_HEDLEY_DMC_VERSION_CHECK
744#if defined(JSON_HEDLEY_DMC_VERSION)
745 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
747 #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0)
750#if defined(JSON_HEDLEY_COMPCERT_VERSION)
751 #undef JSON_HEDLEY_COMPCERT_VERSION
753#if defined(__COMPCERT_VERSION__)
754 #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100)
757#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK)
758 #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
760#if defined(JSON_HEDLEY_COMPCERT_VERSION)
761 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
763 #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0)
766#if defined(JSON_HEDLEY_PELLES_VERSION)
767 #undef JSON_HEDLEY_PELLES_VERSION
770 #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
773#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK)
774 #undef JSON_HEDLEY_PELLES_VERSION_CHECK
776#if defined(JSON_HEDLEY_PELLES_VERSION)
777 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
779 #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0)
782#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
783 #undef JSON_HEDLEY_MCST_LCC_VERSION
785#if defined(__LCC__) && defined(__LCC_MINOR__)
786 #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__)
789#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK)
790 #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
792#if defined(JSON_HEDLEY_MCST_LCC_VERSION)
793 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
795 #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0)
798#if defined(JSON_HEDLEY_GCC_VERSION)
799 #undef JSON_HEDLEY_GCC_VERSION
802 defined(JSON_HEDLEY_GNUC_VERSION) && \
803 !defined(__clang__) && \
804 !defined(JSON_HEDLEY_INTEL_VERSION) && \
805 !defined(JSON_HEDLEY_PGI_VERSION) && \
806 !defined(JSON_HEDLEY_ARM_VERSION) && \
807 !defined(JSON_HEDLEY_CRAY_VERSION) && \
808 !defined(JSON_HEDLEY_TI_VERSION) && \
809 !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \
810 !defined(JSON_HEDLEY_TI_CL430_VERSION) && \
811 !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \
812 !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \
813 !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \
814 !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \
815 !defined(__COMPCERT__) && \
816 !defined(JSON_HEDLEY_MCST_LCC_VERSION)
817 #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION
820#if defined(JSON_HEDLEY_GCC_VERSION_CHECK)
821 #undef JSON_HEDLEY_GCC_VERSION_CHECK
823#if defined(JSON_HEDLEY_GCC_VERSION)
824 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch))
826 #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0)
829#if defined(JSON_HEDLEY_HAS_ATTRIBUTE)
830 #undef JSON_HEDLEY_HAS_ATTRIBUTE
833 defined(__has_attribute) && \
835 (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \
837# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
839# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0)
842#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE)
843 #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
845#if defined(__has_attribute)
846 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
848 #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
851#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE)
852 #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
854#if defined(__has_attribute)
855 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
857 #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
860#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE)
861 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
864 defined(__has_cpp_attribute) && \
865 defined(__cplusplus) && \
866 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0))
867 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
869 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
872#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS)
873 #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
875#if !defined(__cplusplus) || !defined(__has_cpp_attribute)
876 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
878 !defined(JSON_HEDLEY_PGI_VERSION) && \
879 !defined(JSON_HEDLEY_IAR_VERSION) && \
880 (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \
881 (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0))
882 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
884 #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0)
887#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
888 #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
890#if defined(__has_cpp_attribute) && defined(__cplusplus)
891 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
893 #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
896#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
897 #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
899#if defined(__has_cpp_attribute) && defined(__cplusplus)
900 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute)
902 #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
905#if defined(JSON_HEDLEY_HAS_BUILTIN)
906 #undef JSON_HEDLEY_HAS_BUILTIN
908#if defined(__has_builtin)
909 #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
911 #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0)
914#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN)
915 #undef JSON_HEDLEY_GNUC_HAS_BUILTIN
917#if defined(__has_builtin)
918 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
920 #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
923#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN)
924 #undef JSON_HEDLEY_GCC_HAS_BUILTIN
926#if defined(__has_builtin)
927 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin)
929 #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
932#if defined(JSON_HEDLEY_HAS_FEATURE)
933 #undef JSON_HEDLEY_HAS_FEATURE
935#if defined(__has_feature)
936 #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
938 #define JSON_HEDLEY_HAS_FEATURE(feature) (0)
941#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE)
942 #undef JSON_HEDLEY_GNUC_HAS_FEATURE
944#if defined(__has_feature)
945 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
947 #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
950#if defined(JSON_HEDLEY_GCC_HAS_FEATURE)
951 #undef JSON_HEDLEY_GCC_HAS_FEATURE
953#if defined(__has_feature)
954 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature)
956 #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
959#if defined(JSON_HEDLEY_HAS_EXTENSION)
960 #undef JSON_HEDLEY_HAS_EXTENSION
962#if defined(__has_extension)
963 #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
965 #define JSON_HEDLEY_HAS_EXTENSION(extension) (0)
968#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION)
969 #undef JSON_HEDLEY_GNUC_HAS_EXTENSION
971#if defined(__has_extension)
972 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
974 #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
977#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION)
978 #undef JSON_HEDLEY_GCC_HAS_EXTENSION
980#if defined(__has_extension)
981 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension)
983 #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
986#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
987 #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
989#if defined(__has_declspec_attribute)
990 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute)
992 #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
995#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
996 #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
998#if defined(__has_declspec_attribute)
999 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1001 #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1004#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
1005 #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
1007#if defined(__has_declspec_attribute)
1008 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute)
1010 #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1013#if defined(JSON_HEDLEY_HAS_WARNING)
1014 #undef JSON_HEDLEY_HAS_WARNING
1016#if defined(__has_warning)
1017 #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning)
1019 #define JSON_HEDLEY_HAS_WARNING(warning) (0)
1022#if defined(JSON_HEDLEY_GNUC_HAS_WARNING)
1023 #undef JSON_HEDLEY_GNUC_HAS_WARNING
1025#if defined(__has_warning)
1026 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1028 #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch)
1031#if defined(JSON_HEDLEY_GCC_HAS_WARNING)
1032 #undef JSON_HEDLEY_GCC_HAS_WARNING
1034#if defined(__has_warning)
1035 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning)
1037 #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
1041 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1042 defined(__clang__) || \
1043 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1044 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1045 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1046 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
1047 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1048 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1049 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1050 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1051 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1052 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \
1053 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1054 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1055 JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \
1056 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \
1057 JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \
1058 (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR))
1059 #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value)
1060#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1061 #define JSON_HEDLEY_PRAGMA(value) __pragma(value)
1063 #define JSON_HEDLEY_PRAGMA(value)
1066#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH)
1067 #undef JSON_HEDLEY_DIAGNOSTIC_PUSH
1069#if defined(JSON_HEDLEY_DIAGNOSTIC_POP)
1070 #undef JSON_HEDLEY_DIAGNOSTIC_POP
1072#if defined(__clang__)
1073 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1074 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1075#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1076 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1077 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1078#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1079 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1080 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1082 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
1083 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1084 #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
1085 #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
1086#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0)
1087 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
1088 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
1090 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1091 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1092 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \
1093 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1094 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1095 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1096 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
1097 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
1098#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1099 #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
1100 #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
1102 #define JSON_HEDLEY_DIAGNOSTIC_PUSH
1103 #define JSON_HEDLEY_DIAGNOSTIC_POP
1108#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1109 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
1111#if defined(__cplusplus)
1112# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat")
1113# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions")
1114# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions")
1115# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1116 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1117 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1118 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1119 _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \
1121 JSON_HEDLEY_DIAGNOSTIC_POP
1123# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1124 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1125 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1126 _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
1128 JSON_HEDLEY_DIAGNOSTIC_POP
1131# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
1132 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1133 _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
1135 JSON_HEDLEY_DIAGNOSTIC_POP
1139#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
1140 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
1143#if defined(JSON_HEDLEY_CONST_CAST)
1144 #undef JSON_HEDLEY_CONST_CAST
1146#if defined(__cplusplus)
1147# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
1149 JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \
1150 JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \
1151 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1152# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \
1153 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1154 JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
1156 JSON_HEDLEY_DIAGNOSTIC_POP \
1159# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr))
1162#if defined(JSON_HEDLEY_REINTERPRET_CAST)
1163 #undef JSON_HEDLEY_REINTERPRET_CAST
1165#if defined(__cplusplus)
1166 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
1168 #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr))
1171#if defined(JSON_HEDLEY_STATIC_CAST)
1172 #undef JSON_HEDLEY_STATIC_CAST
1174#if defined(__cplusplus)
1175 #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
1177 #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr))
1180#if defined(JSON_HEDLEY_CPP_CAST)
1181 #undef JSON_HEDLEY_CPP_CAST
1183#if defined(__cplusplus)
1184# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast")
1185# define JSON_HEDLEY_CPP_CAST(T, expr) \
1186 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1187 _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \
1189 JSON_HEDLEY_DIAGNOSTIC_POP
1190# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0)
1191# define JSON_HEDLEY_CPP_CAST(T, expr) \
1192 JSON_HEDLEY_DIAGNOSTIC_PUSH \
1193 _Pragma("diag_suppress=Pe137") \
1194 JSON_HEDLEY_DIAGNOSTIC_POP
1196# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr))
1199# define JSON_HEDLEY_CPP_CAST(T, expr) (expr)
1202#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
1203 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1205#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
1206 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
1207#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1208 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
1209#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1210 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786))
1211#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1212 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445")
1213#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1214 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1215#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1216 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1217#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1218 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996))
1219#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1220 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
1222 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1223 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1224 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1225 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1226 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1227 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1228 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1229 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1230 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1231 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1232 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0)
1233 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
1234#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus)
1235 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
1236#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus)
1237 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
1238#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1239 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215")
1240#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0)
1241 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
1243 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
1246#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
1247 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1249#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
1250 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
1251#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1252 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)")
1253#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1254 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161))
1255#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1256 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
1257#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0)
1258 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
1259#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0)
1260 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068))
1262 JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \
1263 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1264 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1265 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0)
1266 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1267#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0)
1268 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
1269#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1270 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
1271#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1272 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161")
1274 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
1277#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
1278 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1280#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes")
1281 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
1282#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0)
1283 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
1284#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0)
1285 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
1286#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1287 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292))
1288#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0)
1289 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
1290#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0)
1291 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098")
1292#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0)
1293 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1294#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
1295 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)")
1297 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1298 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1299 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0)
1300 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173")
1301#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1302 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097")
1303#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1304 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
1306 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
1309#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
1310 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1312#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual")
1313 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
1314#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
1315 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)")
1316#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0)
1317 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
1319 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
1322#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION)
1323 #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1325#if JSON_HEDLEY_HAS_WARNING("-Wunused-function")
1326 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"")
1327#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0)
1328 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
1329#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0)
1330 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505))
1331#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1332 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142")
1334 #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
1337#if defined(JSON_HEDLEY_DEPRECATED)
1338 #undef JSON_HEDLEY_DEPRECATED
1340#if defined(JSON_HEDLEY_DEPRECATED_FOR)
1341 #undef JSON_HEDLEY_DEPRECATED_FOR
1344 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1345 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1346 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since))
1347 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
1349 (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
1350 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1351 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1352 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1353 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \
1354 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1355 JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \
1356 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \
1357 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \
1358 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1359 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \
1360 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1361 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
1362 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
1363#elif defined(__cplusplus) && (__cplusplus >= 201402L)
1364 #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]])
1365 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]])
1367 JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \
1368 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1369 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1370 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1371 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1372 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1373 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1374 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1375 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1376 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1377 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1378 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1379 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1380 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1381 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1382 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1383 #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
1384 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
1386 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1387 JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \
1388 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1389 #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated)
1390 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
1391#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1392 #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated")
1393 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
1395 #define JSON_HEDLEY_DEPRECATED(since)
1396 #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
1399#if defined(JSON_HEDLEY_UNAVAILABLE)
1400 #undef JSON_HEDLEY_UNAVAILABLE
1403 JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \
1404 JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \
1405 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1406 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1407 #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since)))
1409 #define JSON_HEDLEY_UNAVAILABLE(available_since)
1412#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT)
1413 #undef JSON_HEDLEY_WARN_UNUSED_RESULT
1415#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG)
1416 #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
1419 JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
1420 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
1421 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1422 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1423 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1424 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1425 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1426 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1427 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1428 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1429 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1430 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1431 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1432 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1433 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1434 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1435 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1436 #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
1437 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__))
1438#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
1439 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1440 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
1441#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
1442 #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1443 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
1444#elif defined(_Check_return_)
1445 #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_
1446 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
1448 #define JSON_HEDLEY_WARN_UNUSED_RESULT
1449 #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
1452#if defined(JSON_HEDLEY_SENTINEL)
1453 #undef JSON_HEDLEY_SENTINEL
1456 JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \
1457 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1458 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1459 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
1460 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1461 #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
1463 #define JSON_HEDLEY_SENTINEL(position)
1466#if defined(JSON_HEDLEY_NO_RETURN)
1467 #undef JSON_HEDLEY_NO_RETURN
1469#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1470 #define JSON_HEDLEY_NO_RETURN __noreturn
1472 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1473 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1474 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1475#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1476 #define JSON_HEDLEY_NO_RETURN _Noreturn
1477#elif defined(__cplusplus) && (__cplusplus >= 201103L)
1478 #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
1480 JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \
1481 JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \
1482 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1483 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1484 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1485 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1486 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1487 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1488 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1489 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1490 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1491 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1492 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1493 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1494 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1495 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1496 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1497 #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__))
1498#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1499 #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return")
1501 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1502 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1503 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1504#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1505 #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
1506#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1507 #define JSON_HEDLEY_NO_RETURN __attribute((noreturn))
1508#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1509 #define JSON_HEDLEY_NO_RETURN __declspec(noreturn)
1511 #define JSON_HEDLEY_NO_RETURN
1514#if defined(JSON_HEDLEY_NO_ESCAPE)
1515 #undef JSON_HEDLEY_NO_ESCAPE
1517#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape)
1518 #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__))
1520 #define JSON_HEDLEY_NO_ESCAPE
1523#if defined(JSON_HEDLEY_UNREACHABLE)
1524 #undef JSON_HEDLEY_UNREACHABLE
1526#if defined(JSON_HEDLEY_UNREACHABLE_RETURN)
1527 #undef JSON_HEDLEY_UNREACHABLE_RETURN
1529#if defined(JSON_HEDLEY_ASSUME)
1530 #undef JSON_HEDLEY_ASSUME
1533 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1534 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1535 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1536 #define JSON_HEDLEY_ASSUME(expr) __assume(expr)
1537#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume)
1538 #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr)
1540 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1541 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1542 #if defined(__cplusplus)
1543 #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr)
1545 #define JSON_HEDLEY_ASSUME(expr) _nassert(expr)
1549 (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \
1550 JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \
1551 JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \
1552 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1553 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \
1554 JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \
1555 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1556 #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable()
1557#elif defined(JSON_HEDLEY_ASSUME)
1558 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1560#if !defined(JSON_HEDLEY_ASSUME)
1561 #if defined(JSON_HEDLEY_UNREACHABLE)
1562 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1)))
1564 #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr)
1567#if defined(JSON_HEDLEY_UNREACHABLE)
1569 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1570 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0)
1571 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value))
1573 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE()
1576 #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value)
1578#if !defined(JSON_HEDLEY_UNREACHABLE)
1579 #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0)
1583#if JSON_HEDLEY_HAS_WARNING("-Wpedantic")
1584 #pragma clang diagnostic ignored "-Wpedantic"
1586#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
1587 #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
1589#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0)
1590 #if defined(__clang__)
1591 #pragma clang diagnostic ignored "-Wvariadic-macros"
1592 #elif defined(JSON_HEDLEY_GCC_VERSION)
1593 #pragma GCC diagnostic ignored "-Wvariadic-macros"
1596#if defined(JSON_HEDLEY_NON_NULL)
1597 #undef JSON_HEDLEY_NON_NULL
1600 JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \
1601 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1602 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1603 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
1604 #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
1606 #define JSON_HEDLEY_NON_NULL(...)
1610#if defined(JSON_HEDLEY_PRINTF_FORMAT)
1611 #undef JSON_HEDLEY_PRINTF_FORMAT
1613#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO)
1614 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check)))
1615#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO)
1616 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
1618 JSON_HEDLEY_HAS_ATTRIBUTE(format) || \
1619 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1620 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1621 JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \
1622 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1623 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1624 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1625 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1626 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1627 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1628 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1629 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1630 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1631 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1632 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1633 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1634 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1635 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check)))
1636#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0)
1637 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check))
1639 #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check)
1642#if defined(JSON_HEDLEY_CONSTEXPR)
1643 #undef JSON_HEDLEY_CONSTEXPR
1645#if defined(__cplusplus)
1646 #if __cplusplus >= 201103L
1647 #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
1650#if !defined(JSON_HEDLEY_CONSTEXPR)
1651 #define JSON_HEDLEY_CONSTEXPR
1654#if defined(JSON_HEDLEY_PREDICT)
1655 #undef JSON_HEDLEY_PREDICT
1657#if defined(JSON_HEDLEY_LIKELY)
1658 #undef JSON_HEDLEY_LIKELY
1660#if defined(JSON_HEDLEY_UNLIKELY)
1661 #undef JSON_HEDLEY_UNLIKELY
1663#if defined(JSON_HEDLEY_UNPREDICTABLE)
1664 #undef JSON_HEDLEY_UNPREDICTABLE
1666#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
1667 #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
1670 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \
1671 JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \
1672 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1673# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
1674# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
1675# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability))
1676# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 )
1677# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 )
1679 (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
1680 JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \
1681 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1682 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \
1683 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1684 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1685 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1686 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \
1687 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1688 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \
1689 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1690 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1691 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1692 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \
1693 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
1694 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1695# define JSON_HEDLEY_PREDICT(expr, expected, probability) \
1696 (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)))
1697# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \
1699 double hedley_probability_ = (probability); \
1700 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \
1702# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \
1704 double hedley_probability_ = (probability); \
1705 ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \
1707# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
1708# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
1710# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))
1711# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
1712# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
1713# define JSON_HEDLEY_LIKELY(expr) (!!(expr))
1714# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr))
1716#if !defined(JSON_HEDLEY_UNPREDICTABLE)
1717 #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5)
1720#if defined(JSON_HEDLEY_MALLOC)
1721 #undef JSON_HEDLEY_MALLOC
1724 JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \
1725 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1726 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1727 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1728 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1729 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
1730 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1731 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1732 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1733 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1734 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1735 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1736 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1737 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1738 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1739 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1740 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1741 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1742 #define JSON_HEDLEY_MALLOC __attribute__((__malloc__))
1743#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1744 #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory")
1746 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1747 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1748 #define JSON_HEDLEY_MALLOC __declspec(restrict)
1750 #define JSON_HEDLEY_MALLOC
1753#if defined(JSON_HEDLEY_PURE)
1754 #undef JSON_HEDLEY_PURE
1757 JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \
1758 JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \
1759 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1760 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1761 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1762 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1763 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1764 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1765 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1766 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1767 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1768 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1769 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1770 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1771 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1772 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1773 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1774 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1775 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1776# define JSON_HEDLEY_PURE __attribute__((__pure__))
1777#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1778# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data")
1779#elif defined(__cplusplus) && \
1781 JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \
1782 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \
1783 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \
1785# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
1787# define JSON_HEDLEY_PURE
1790#if defined(JSON_HEDLEY_CONST)
1791 #undef JSON_HEDLEY_CONST
1794 JSON_HEDLEY_HAS_ATTRIBUTE(const) || \
1795 JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \
1796 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1797 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1798 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1799 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1800 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1801 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1802 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1803 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1804 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1805 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1806 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1807 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1808 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1809 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1810 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1811 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1812 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1813 #define JSON_HEDLEY_CONST __attribute__((__const__))
1815 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0)
1816 #define JSON_HEDLEY_CONST _Pragma("no_side_effect")
1818 #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE
1821#if defined(JSON_HEDLEY_RESTRICT)
1822 #undef JSON_HEDLEY_RESTRICT
1824#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus)
1825 #define JSON_HEDLEY_RESTRICT restrict
1827 JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \
1828 JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \
1829 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1830 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1831 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1832 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1833 JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \
1834 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1835 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \
1836 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \
1837 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1838 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \
1839 JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \
1840 defined(__clang__) || \
1841 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1842 #define JSON_HEDLEY_RESTRICT __restrict
1843#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus)
1844 #define JSON_HEDLEY_RESTRICT _Restrict
1846 #define JSON_HEDLEY_RESTRICT
1849#if defined(JSON_HEDLEY_INLINE)
1850 #undef JSON_HEDLEY_INLINE
1853 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
1854 (defined(__cplusplus) && (__cplusplus >= 199711L))
1855 #define JSON_HEDLEY_INLINE inline
1857 defined(JSON_HEDLEY_GCC_VERSION) || \
1858 JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0)
1859 #define JSON_HEDLEY_INLINE __inline__
1861 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1862 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
1863 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1864 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \
1865 JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \
1866 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \
1867 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
1868 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1869 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1870 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1871 #define JSON_HEDLEY_INLINE __inline
1873 #define JSON_HEDLEY_INLINE
1876#if defined(JSON_HEDLEY_ALWAYS_INLINE)
1877 #undef JSON_HEDLEY_ALWAYS_INLINE
1880 JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \
1881 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1882 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1883 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1884 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1885 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1886 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1887 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1888 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1889 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1890 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1891 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1892 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1893 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1894 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1895 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1896 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1897 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1898 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1899# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE
1901 JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \
1902 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1903# define JSON_HEDLEY_ALWAYS_INLINE __forceinline
1904#elif defined(__cplusplus) && \
1906 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1907 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1908 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1909 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
1910 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1911 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \
1913# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
1914#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1915# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
1917# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE
1920#if defined(JSON_HEDLEY_NEVER_INLINE)
1921 #undef JSON_HEDLEY_NEVER_INLINE
1924 JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \
1925 JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \
1926 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1927 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1928 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1929 JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \
1930 JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \
1931 (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1932 JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \
1933 (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1934 JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \
1935 (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1936 JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \
1937 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1938 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \
1939 JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
1940 JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \
1941 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \
1942 JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0)
1943 #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__))
1945 JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \
1946 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
1947 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1948#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0)
1949 #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline")
1950#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus)
1951 #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
1952#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
1953 #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never")
1954#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0)
1955 #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline))
1956#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0)
1957 #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline)
1959 #define JSON_HEDLEY_NEVER_INLINE
1962#if defined(JSON_HEDLEY_PRIVATE)
1963 #undef JSON_HEDLEY_PRIVATE
1965#if defined(JSON_HEDLEY_PUBLIC)
1966 #undef JSON_HEDLEY_PUBLIC
1968#if defined(JSON_HEDLEY_IMPORT)
1969 #undef JSON_HEDLEY_IMPORT
1971#if defined(_WIN32) || defined(__CYGWIN__)
1972# define JSON_HEDLEY_PRIVATE
1973# define JSON_HEDLEY_PUBLIC __declspec(dllexport)
1974# define JSON_HEDLEY_IMPORT __declspec(dllimport)
1977 JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \
1978 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
1979 JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \
1980 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
1981 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
1982 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
1984 defined(__TI_EABI__) && \
1986 (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
1987 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \
1990 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
1991# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
1992# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default")))
1994# define JSON_HEDLEY_PRIVATE
1995# define JSON_HEDLEY_PUBLIC
1997# define JSON_HEDLEY_IMPORT extern
2000#if defined(JSON_HEDLEY_NO_THROW)
2001 #undef JSON_HEDLEY_NO_THROW
2004 JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \
2005 JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \
2006 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2007 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2008 #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__))
2010 JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \
2011 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \
2012 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0)
2013 #define JSON_HEDLEY_NO_THROW __declspec(nothrow)
2015 #define JSON_HEDLEY_NO_THROW
2018#if defined(JSON_HEDLEY_FALL_THROUGH)
2019 #undef JSON_HEDLEY_FALL_THROUGH
2022 JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \
2023 JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \
2024 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2025 #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
2026#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough)
2027 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
2028#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
2029 #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
2030#elif defined(__fallthrough)
2031 #define JSON_HEDLEY_FALL_THROUGH __fallthrough
2033 #define JSON_HEDLEY_FALL_THROUGH
2036#if defined(JSON_HEDLEY_RETURNS_NON_NULL)
2037 #undef JSON_HEDLEY_RETURNS_NON_NULL
2040 JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \
2041 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2042 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2043 #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
2044#elif defined(_Ret_notnull_)
2045 #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_
2047 #define JSON_HEDLEY_RETURNS_NON_NULL
2050#if defined(JSON_HEDLEY_ARRAY_PARAM)
2051 #undef JSON_HEDLEY_ARRAY_PARAM
2054 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
2055 !defined(__STDC_NO_VLA__) && \
2056 !defined(__cplusplus) && \
2057 !defined(JSON_HEDLEY_PGI_VERSION) && \
2058 !defined(JSON_HEDLEY_TINYC_VERSION)
2059 #define JSON_HEDLEY_ARRAY_PARAM(name) (name)
2061 #define JSON_HEDLEY_ARRAY_PARAM(name)
2064#if defined(JSON_HEDLEY_IS_CONSTANT)
2065 #undef JSON_HEDLEY_IS_CONSTANT
2067#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR)
2068 #undef JSON_HEDLEY_REQUIRE_CONSTEXPR
2072#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2073 #undef JSON_HEDLEY_IS_CONSTEXPR_
2076 JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
2077 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2078 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2079 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \
2080 JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \
2081 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2082 JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \
2083 (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \
2084 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2085 JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10)
2086 #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
2088#if !defined(__cplusplus)
2090 JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
2091 JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \
2092 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2093 JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \
2094 JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \
2095 JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \
2096 JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24)
2097#if defined(__INTPTR_TYPE__)
2098 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*)
2101 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*)
2105 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
2106 !defined(JSON_HEDLEY_SUNPRO_VERSION) && \
2107 !defined(JSON_HEDLEY_PGI_VERSION) && \
2108 !defined(JSON_HEDLEY_IAR_VERSION)) || \
2109 (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \
2110 JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \
2111 JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \
2112 JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \
2113 JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0)
2114#if defined(__INTPTR_TYPE__)
2115 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0)
2118 #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0)
2121 defined(JSON_HEDLEY_GCC_VERSION) || \
2122 defined(JSON_HEDLEY_INTEL_VERSION) || \
2123 defined(JSON_HEDLEY_TINYC_VERSION) || \
2124 defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \
2125 JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \
2126 defined(JSON_HEDLEY_TI_CL2000_VERSION) || \
2127 defined(JSON_HEDLEY_TI_CL6X_VERSION) || \
2128 defined(JSON_HEDLEY_TI_CL7X_VERSION) || \
2129 defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \
2131# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \
2135 ((void*) ((expr) * 0L) ) : \
2136((struct { char v[sizeof(void) * 2]; } *) 1) \
2142#if defined(JSON_HEDLEY_IS_CONSTEXPR_)
2143 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2144 #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr)
2146 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
2148 #if !defined(JSON_HEDLEY_IS_CONSTANT)
2149 #define JSON_HEDLEY_IS_CONSTANT(expr) (0)
2151 #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
2154#if defined(JSON_HEDLEY_BEGIN_C_DECLS)
2155 #undef JSON_HEDLEY_BEGIN_C_DECLS
2157#if defined(JSON_HEDLEY_END_C_DECLS)
2158 #undef JSON_HEDLEY_END_C_DECLS
2160#if defined(JSON_HEDLEY_C_DECL)
2161 #undef JSON_HEDLEY_C_DECL
2163#if defined(__cplusplus)
2164 #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" {
2165 #define JSON_HEDLEY_END_C_DECLS }
2166 #define JSON_HEDLEY_C_DECL extern "C"
2168 #define JSON_HEDLEY_BEGIN_C_DECLS
2169 #define JSON_HEDLEY_END_C_DECLS
2170 #define JSON_HEDLEY_C_DECL
2173#if defined(JSON_HEDLEY_STATIC_ASSERT)
2174 #undef JSON_HEDLEY_STATIC_ASSERT
2177 !defined(__cplusplus) && ( \
2178 (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
2179 (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \
2180 JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
2181 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
2182 defined(_Static_assert) \
2184# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
2186 (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
2187 JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \
2188 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2189# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message))
2191# define JSON_HEDLEY_STATIC_ASSERT(expr, message)
2194#if defined(JSON_HEDLEY_NULL)
2195 #undef JSON_HEDLEY_NULL
2197#if defined(__cplusplus)
2198 #if __cplusplus >= 201103L
2199 #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
2201 #define JSON_HEDLEY_NULL NULL
2203 #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0)
2206 #define JSON_HEDLEY_NULL NULL
2208 #define JSON_HEDLEY_NULL ((void*) 0)
2211#if defined(JSON_HEDLEY_MESSAGE)
2212 #undef JSON_HEDLEY_MESSAGE
2214#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2215# define JSON_HEDLEY_MESSAGE(msg) \
2216 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2217 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2218 JSON_HEDLEY_PRAGMA(message msg) \
2219 JSON_HEDLEY_DIAGNOSTIC_POP
2221 JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \
2222 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2223# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg)
2224#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0)
2225# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg)
2226#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0)
2227# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2228#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0)
2229# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg))
2231# define JSON_HEDLEY_MESSAGE(msg)
2234#if defined(JSON_HEDLEY_WARNING)
2235 #undef JSON_HEDLEY_WARNING
2237#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas")
2238# define JSON_HEDLEY_WARNING(msg) \
2239 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2240 JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
2241 JSON_HEDLEY_PRAGMA(clang warning msg) \
2242 JSON_HEDLEY_DIAGNOSTIC_POP
2244 JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \
2245 JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \
2246 JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0)
2247# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg)
2249 JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \
2250 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2251# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg))
2253# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg)
2256#if defined(JSON_HEDLEY_REQUIRE)
2257 #undef JSON_HEDLEY_REQUIRE
2259#if defined(JSON_HEDLEY_REQUIRE_MSG)
2260 #undef JSON_HEDLEY_REQUIRE_MSG
2262#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if)
2263# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat")
2264# define JSON_HEDLEY_REQUIRE(expr) \
2265 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2266 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2267 __attribute__((diagnose_if(!(expr), #expr, "error"))) \
2268 JSON_HEDLEY_DIAGNOSTIC_POP
2269# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \
2270 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2271 _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
2272 __attribute__((diagnose_if(!(expr), msg, "error"))) \
2273 JSON_HEDLEY_DIAGNOSTIC_POP
2275# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error")))
2276# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error")))
2279# define JSON_HEDLEY_REQUIRE(expr)
2280# define JSON_HEDLEY_REQUIRE_MSG(expr,msg)
2283#if defined(JSON_HEDLEY_FLAGS)
2284 #undef JSON_HEDLEY_FLAGS
2286#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion"))
2287 #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__))
2289 #define JSON_HEDLEY_FLAGS
2292#if defined(JSON_HEDLEY_FLAGS_CAST)
2293 #undef JSON_HEDLEY_FLAGS_CAST
2295#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0)
2296# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \
2297 JSON_HEDLEY_DIAGNOSTIC_PUSH \
2298 _Pragma("warning(disable:188)") \
2300 JSON_HEDLEY_DIAGNOSTIC_POP \
2303# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr)
2306#if defined(JSON_HEDLEY_EMPTY_BASES)
2307 #undef JSON_HEDLEY_EMPTY_BASES
2310 (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \
2311 JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0)
2312 #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases)
2314 #define JSON_HEDLEY_EMPTY_BASES
2319#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
2320 #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
2322#if defined(__clang__)
2323 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0)
2325 #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch)
2328#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE)
2329 #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
2331#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute)
2333#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
2334 #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
2336#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
2338#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN)
2339 #undef JSON_HEDLEY_CLANG_HAS_BUILTIN
2341#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin)
2343#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE)
2344 #undef JSON_HEDLEY_CLANG_HAS_FEATURE
2346#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature)
2348#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION)
2349 #undef JSON_HEDLEY_CLANG_HAS_EXTENSION
2351#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension)
2353#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
2354 #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
2356#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
2358#if defined(JSON_HEDLEY_CLANG_HAS_WARNING)
2359 #undef JSON_HEDLEY_CLANG_HAS_WARNING
2361#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning)
2373#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK)
2374 #if defined(__clang__)
2375 #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
2376 #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
2378 #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
2379 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800
2380 #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
2387#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
2388 #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
2389 #define JSON_HAS_CPP_20
2390 #define JSON_HAS_CPP_17
2391 #define JSON_HAS_CPP_14
2392 #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
2393 #define JSON_HAS_CPP_17
2394 #define JSON_HAS_CPP_14
2395 #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
2396 #define JSON_HAS_CPP_14
2399 #define JSON_HAS_CPP_11
2403 #if __has_include(<version>)
2408#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM)
2409 #ifdef JSON_HAS_CPP_17
2410 #if defined(__cpp_lib_filesystem)
2411 #define JSON_HAS_FILESYSTEM 1
2412 #elif defined(__cpp_lib_experimental_filesystem)
2413 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2414 #elif !defined(__has_include)
2415 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2416 #elif __has_include(<filesystem>)
2417 #define JSON_HAS_FILESYSTEM 1
2418 #elif __has_include(<experimental/filesystem>)
2419 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1
2423 #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8
2424 #undef JSON_HAS_FILESYSTEM
2425 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2429 #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8
2430 #undef JSON_HAS_FILESYSTEM
2431 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2435 #if defined(__clang_major__) && __clang_major__ < 7
2436 #undef JSON_HAS_FILESYSTEM
2437 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2441 #if defined(_MSC_VER) && _MSC_VER < 1914
2442 #undef JSON_HAS_FILESYSTEM
2443 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2447 #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
2448 #undef JSON_HAS_FILESYSTEM
2449 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2453 #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
2454 #undef JSON_HAS_FILESYSTEM
2455 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2460#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM
2461 #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0
2464#ifndef JSON_HAS_FILESYSTEM
2465 #define JSON_HAS_FILESYSTEM 0
2468#ifndef JSON_HAS_THREE_WAY_COMPARISON
2469 #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \
2470 && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L
2471 #define JSON_HAS_THREE_WAY_COMPARISON 1
2473 #define JSON_HAS_THREE_WAY_COMPARISON 0
2477#ifndef JSON_HAS_RANGES
2479 #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
2480 #define JSON_HAS_RANGES 0
2481 #elif defined(__cpp_lib_ranges)
2482 #define JSON_HAS_RANGES 1
2484 #define JSON_HAS_RANGES 0
2488#ifdef JSON_HAS_CPP_17
2489 #define JSON_INLINE_VARIABLE inline
2491 #define JSON_INLINE_VARIABLE
2494#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address)
2495 #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]]
2497 #define JSON_NO_UNIQUE_ADDRESS
2501#if defined(__clang__)
2502 #pragma clang diagnostic push
2503 #pragma clang diagnostic ignored "-Wdocumentation"
2504 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
2508#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION)
2509 #define JSON_THROW(exception) throw exception
2510 #define JSON_TRY try
2511 #define JSON_CATCH(exception) catch(exception)
2512 #define JSON_INTERNAL_CATCH(exception) catch(exception)
2515 #define JSON_THROW(exception) std::abort()
2516 #define JSON_TRY if(true)
2517 #define JSON_CATCH(exception) if(false)
2518 #define JSON_INTERNAL_CATCH(exception) if(false)
2522#if defined(JSON_THROW_USER)
2524 #define JSON_THROW JSON_THROW_USER
2526#if defined(JSON_TRY_USER)
2528 #define JSON_TRY JSON_TRY_USER
2530#if defined(JSON_CATCH_USER)
2532 #define JSON_CATCH JSON_CATCH_USER
2533 #undef JSON_INTERNAL_CATCH
2534 #define JSON_INTERNAL_CATCH JSON_CATCH_USER
2536#if defined(JSON_INTERNAL_CATCH_USER)
2537 #undef JSON_INTERNAL_CATCH
2538 #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER
2542#if !defined(JSON_ASSERT)
2544 #define JSON_ASSERT(x) assert(x)
2548#if defined(JSON_TESTS_PRIVATE)
2549 #define JSON_PRIVATE_UNLESS_TESTED public
2551 #define JSON_PRIVATE_UNLESS_TESTED private
2559#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \
2560 template<typename BasicJsonType> \
2561 inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
2563 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2564 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2565 auto it = std::find_if(std::begin(m), std::end(m), \
2566 [e](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2568 return ej_pair.first == e; \
2570 j = ((it != std::end(m)) ? it : std::begin(m))->second; \
2572 template<typename BasicJsonType> \
2573 inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \
2575 static_assert(std::is_enum<ENUM_TYPE>::value, #ENUM_TYPE " must be an enum!"); \
2576 static const std::pair<ENUM_TYPE, BasicJsonType> m[] = __VA_ARGS__; \
2577 auto it = std::find_if(std::begin(m), std::end(m), \
2578 [&j](const std::pair<ENUM_TYPE, BasicJsonType>& ej_pair) -> bool \
2580 return ej_pair.second == j; \
2582 e = ((it != std::end(m)) ? it : std::begin(m))->first; \
2588#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \
2589 template<template<typename, typename, typename...> class ObjectType, \
2590 template<typename, typename...> class ArrayType, \
2591 class StringType, class BooleanType, class NumberIntegerType, \
2592 class NumberUnsignedType, class NumberFloatType, \
2593 template<typename> class AllocatorType, \
2594 template<typename, typename = void> class JSONSerializer, \
2596 class CustomBaseClass>
2598#define NLOHMANN_BASIC_JSON_TPL \
2599 basic_json<ObjectType, ArrayType, StringType, BooleanType, \
2600 NumberIntegerType, NumberUnsignedType, NumberFloatType, \
2601 AllocatorType, JSONSerializer, BinaryType, CustomBaseClass>
2605#define NLOHMANN_JSON_EXPAND( x ) x
2606#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME
2607#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \
2608 NLOHMANN_JSON_PASTE64, \
2609 NLOHMANN_JSON_PASTE63, \
2610 NLOHMANN_JSON_PASTE62, \
2611 NLOHMANN_JSON_PASTE61, \
2612 NLOHMANN_JSON_PASTE60, \
2613 NLOHMANN_JSON_PASTE59, \
2614 NLOHMANN_JSON_PASTE58, \
2615 NLOHMANN_JSON_PASTE57, \
2616 NLOHMANN_JSON_PASTE56, \
2617 NLOHMANN_JSON_PASTE55, \
2618 NLOHMANN_JSON_PASTE54, \
2619 NLOHMANN_JSON_PASTE53, \
2620 NLOHMANN_JSON_PASTE52, \
2621 NLOHMANN_JSON_PASTE51, \
2622 NLOHMANN_JSON_PASTE50, \
2623 NLOHMANN_JSON_PASTE49, \
2624 NLOHMANN_JSON_PASTE48, \
2625 NLOHMANN_JSON_PASTE47, \
2626 NLOHMANN_JSON_PASTE46, \
2627 NLOHMANN_JSON_PASTE45, \
2628 NLOHMANN_JSON_PASTE44, \
2629 NLOHMANN_JSON_PASTE43, \
2630 NLOHMANN_JSON_PASTE42, \
2631 NLOHMANN_JSON_PASTE41, \
2632 NLOHMANN_JSON_PASTE40, \
2633 NLOHMANN_JSON_PASTE39, \
2634 NLOHMANN_JSON_PASTE38, \
2635 NLOHMANN_JSON_PASTE37, \
2636 NLOHMANN_JSON_PASTE36, \
2637 NLOHMANN_JSON_PASTE35, \
2638 NLOHMANN_JSON_PASTE34, \
2639 NLOHMANN_JSON_PASTE33, \
2640 NLOHMANN_JSON_PASTE32, \
2641 NLOHMANN_JSON_PASTE31, \
2642 NLOHMANN_JSON_PASTE30, \
2643 NLOHMANN_JSON_PASTE29, \
2644 NLOHMANN_JSON_PASTE28, \
2645 NLOHMANN_JSON_PASTE27, \
2646 NLOHMANN_JSON_PASTE26, \
2647 NLOHMANN_JSON_PASTE25, \
2648 NLOHMANN_JSON_PASTE24, \
2649 NLOHMANN_JSON_PASTE23, \
2650 NLOHMANN_JSON_PASTE22, \
2651 NLOHMANN_JSON_PASTE21, \
2652 NLOHMANN_JSON_PASTE20, \
2653 NLOHMANN_JSON_PASTE19, \
2654 NLOHMANN_JSON_PASTE18, \
2655 NLOHMANN_JSON_PASTE17, \
2656 NLOHMANN_JSON_PASTE16, \
2657 NLOHMANN_JSON_PASTE15, \
2658 NLOHMANN_JSON_PASTE14, \
2659 NLOHMANN_JSON_PASTE13, \
2660 NLOHMANN_JSON_PASTE12, \
2661 NLOHMANN_JSON_PASTE11, \
2662 NLOHMANN_JSON_PASTE10, \
2663 NLOHMANN_JSON_PASTE9, \
2664 NLOHMANN_JSON_PASTE8, \
2665 NLOHMANN_JSON_PASTE7, \
2666 NLOHMANN_JSON_PASTE6, \
2667 NLOHMANN_JSON_PASTE5, \
2668 NLOHMANN_JSON_PASTE4, \
2669 NLOHMANN_JSON_PASTE3, \
2670 NLOHMANN_JSON_PASTE2, \
2671 NLOHMANN_JSON_PASTE1)(__VA_ARGS__))
2672#define NLOHMANN_JSON_PASTE2(func, v1) func(v1)
2673#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2)
2674#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3)
2675#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4)
2676#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5)
2677#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6)
2678#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7)
2679#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8)
2680#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9)
2681#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10)
2682#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
2683#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12)
2684#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13)
2685#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14)
2686#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15)
2687#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16)
2688#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17)
2689#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18)
2690#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19)
2691#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
2692#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
2693#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22)
2694#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23)
2695#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24)
2696#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
2697#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
2698#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27)
2699#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28)
2700#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29)
2701#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
2702#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
2703#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32)
2704#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33)
2705#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34)
2706#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35)
2707#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36)
2708#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37)
2709#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38)
2710#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39)
2711#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40)
2712#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41)
2713#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42)
2714#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43)
2715#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44)
2716#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45)
2717#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46)
2718#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47)
2719#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48)
2720#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49)
2721#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50)
2722#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51)
2723#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52)
2724#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53)
2725#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54)
2726#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55)
2727#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56)
2728#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57)
2729#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58)
2730#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59)
2731#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60)
2732#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61)
2733#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62)
2734#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63)
2736#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1;
2737#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1);
2738#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1);
2745#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \
2746 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2747 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2749#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2750 friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2751 friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2758#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \
2759 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2760 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
2762#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \
2763 inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
2764 inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { const Type nlohmann_json_default_obj{}; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) }
2773#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
2774 namespace detail { \
2775 using std::std_name; \
2777 template<typename... T> \
2778 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2781 namespace detail2 { \
2782 struct std_name##_tag \
2786 template<typename... T> \
2787 std_name##_tag std_name(T&&...); \
2789 template<typename... T> \
2790 using result_of_##std_name = decltype(std_name(std::declval<T>()...)); \
2792 template<typename... T> \
2793 struct would_call_std_##std_name \
2795 static constexpr auto const value = ::nlohmann::detail:: \
2796 is_detected_exact<std_name##_tag, result_of_##std_name, T...>::value; \
2800 template<typename... T> \
2801 struct would_call_std_##std_name : detail2::would_call_std_##std_name<T...> \
2805#ifndef JSON_USE_IMPLICIT_CONVERSIONS
2806 #define JSON_USE_IMPLICIT_CONVERSIONS 1
2809#if JSON_USE_IMPLICIT_CONVERSIONS
2810 #define JSON_EXPLICIT
2812 #define JSON_EXPLICIT explicit
2815#ifndef JSON_DISABLE_ENUM_SERIALIZATION
2816 #define JSON_DISABLE_ENUM_SERIALIZATION 0
2819#ifndef JSON_USE_GLOBAL_UDLS
2820 #define JSON_USE_GLOBAL_UDLS 1
2823#if JSON_HAS_THREE_WAY_COMPARISON
2886#if JSON_HAS_THREE_WAY_COMPARISON
2887 inline std::partial_ordering operator<=>(
const value_t lhs,
const value_t rhs)
noexcept
2892 static constexpr std::array<std::uint8_t, 9> order = {{
2899 const auto l_index =
static_cast<std::size_t>(lhs);
2900 const auto r_index =
static_cast<std::size_t>(rhs);
2901#if JSON_HAS_THREE_WAY_COMPARISON
2902 if (l_index < order.size() && r_index < order.size())
2904 return order[l_index] <=> order[r_index];
2906 return std::partial_ordering::unordered;
2908 return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index];
2916#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__)
2919 return std::is_lt(lhs <=> rhs);
2957template<
typename StringType>
2959 const StringType& t)
2962 for (
auto pos = s.find(f);
2963 pos != StringType::npos;
2964 s.replace(pos, f.size(), t),
2965 pos = s.find(f, pos + t.size()))
2976template<
typename StringType>
2977inline StringType
escape(StringType s)
2991template<
typename StringType>
3032 constexpr operator size_t()
const
3057#include <type_traits>
3068using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
3070#ifdef JSON_HAS_CPP_14
3073using std::enable_if_t;
3074using std::index_sequence;
3075using std::make_index_sequence;
3076using std::index_sequence_for;
3081template<
bool B,
typename T =
void>
3082using enable_if_t =
typename std::enable_if<B, T>::type;
3108template <
typename T, T... Ints>
3109struct integer_sequence
3114 return sizeof...(Ints);
3123template <
size_t... Ints>
3126namespace utility_internal
3129template <
typename Seq,
size_t SeqSize,
size_t Rem>
3133template <
typename T, T... Ints,
size_t SeqSize>
3134struct Extend<integer_sequence<T, Ints...>, SeqSize, 0>
3139template <
typename T, T... Ints,
size_t SeqSize>
3147template <
typename T,
size_t N>
3154template <
typename T>
3169template <
typename T, T N>
3185template <
typename... Ts>
3194template<>
struct priority_tag<0> {};
3203#ifndef JSON_HAS_CPP_17
3204 template<
typename T>
3208template<
typename T,
typename... Args>
3209inline constexpr std::array<T,
sizeof...(Args)>
make_array(Args&& ... args)
3211 return std::array<T,
sizeof...(Args)> {{
static_cast<T
>(std::forward<Args>(args))...}};
3229#include <type_traits>
3257template<
typename It,
typename =
void>
3258struct iterator_types {};
3260template<
typename It>
3261struct iterator_types <
3263 void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
3264 typename It::reference, typename It::iterator_category >>
3275template<
typename T,
typename =
void>
3287struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
3354#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3355 #define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3380 template<
typename T =
void,
typename SFINAE =
void>
3385 template<
template<
typename U,
typename V,
typename... Args>
class ObjectType =
3387 template<
typename U,
typename... Args>
class ArrayType = std::vector,
3388 class StringType = std::string,
class BooleanType = bool,
3389 class NumberIntegerType = std::int64_t,
3390 class NumberUnsignedType = std::uint64_t,
3391 class NumberFloatType = double,
3392 template<
typename U>
class AllocatorType = std::allocator,
3393 template<
typename T,
typename SFINAE =
void>
class JSONSerializer =
3395 class BinaryType = std::vector<std::uint8_t>,
3396 class CustomBaseClass =
void>
3401 template<
typename RefStringType>
3412 template<
class Key,
class T,
class IgnoredLess,
class Allocator>
3449template<
typename>
struct is_basic_json : std::false_type {};
3457template<
typename BasicJsonContext>
3458struct is_basic_json_context :
3459 std::integral_constant < bool,
3460 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
3461 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
3472struct is_json_ref : std::false_type {};
3475struct is_json_ref<json_ref<T>> : std::true_type {};
3502template<
typename T,
typename... Args>
3505template<
typename T,
typename... Args>
3508template<
typename T,
typename U>
3512template<
typename BasicJsonType,
typename T,
typename =
void>
3513struct has_from_json : std::false_type {};
3519template <
typename BasicJsonType,
typename T>
3522 static constexpr bool value = is_detected<get_template_function, const BasicJsonType&, T>::value;
3525template<
typename BasicJsonType,
typename T>
3526struct has_from_json < BasicJsonType, T,
enable_if_t < !is_basic_json<T>::
value >>
3528 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3530 static constexpr bool value =
3532 const BasicJsonType&, T&>
::value;
3537template<
typename BasicJsonType,
typename T,
typename =
void>
3540template<
typename BasicJsonType,
typename T>
3541struct has_non_default_from_json < BasicJsonType, T,
enable_if_t < !is_basic_json<T>::
value >>
3543 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3545 static constexpr bool value =
3552template<
typename BasicJsonType,
typename T,
typename =
void>
3555template<
typename BasicJsonType,
typename T>
3556struct has_to_json < BasicJsonType, T,
enable_if_t < !is_basic_json<T>::
value >>
3558 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
3560 static constexpr bool value =
3569struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
3572template<
typename BasicJsonType>
3573struct actual_object_comparator
3577 using type =
typename std::conditional < has_key_compare<object_t>::value,
3581template<
typename BasicJsonType>
3589template<
class...>
struct conjunction : std::true_type { };
3590template<
class B>
struct conjunction<B> : B { };
3591template<
class B,
class... Bn>
3592struct conjunction<B, Bn...>
3593: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
3596template<
class B>
struct negation : std::integral_constant < bool, !B::value > { };
3601template <
typename T>
3602struct is_default_constructible : std::is_default_constructible<T> {};
3604template <
typename T1,
typename T2>
3605struct is_default_constructible<
std::pair<T1, T2>>
3606 : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3608template <
typename T1,
typename T2>
3609struct is_default_constructible<const
std::pair<T1, T2>>
3610 : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
3612template <
typename... Ts>
3613struct is_default_constructible<
std::tuple<Ts...>>
3614 : conjunction<is_default_constructible<Ts>...> {};
3616template <
typename... Ts>
3617struct is_default_constructible<const
std::tuple<Ts...>>
3618 : conjunction<is_default_constructible<Ts>...> {};
3621template <
typename T,
typename... Args>
3622struct is_constructible : std::is_constructible<T, Args...> {};
3624template <
typename T1,
typename T2>
3625struct is_constructible<
std::pair<T1, T2>> : is_default_constructible<std::pair<T1, T2>> {};
3627template <
typename T1,
typename T2>
3628struct is_constructible<const
std::pair<T1, T2>> : is_default_constructible<const std::pair<T1, T2>> {};
3630template <
typename... Ts>
3631struct is_constructible<
std::tuple<Ts...>> : is_default_constructible<std::tuple<Ts...>> {};
3633template <
typename... Ts>
3634struct is_constructible<const
std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
3637template<
typename T,
typename =
void>
3638struct is_iterator_traits : std::false_type {};
3641struct is_iterator_traits<iterator_traits<T>>
3647 static constexpr auto value =
3659 using t_ref =
typename std::add_lvalue_reference<T>::type;
3668 is_iterator_traits<iterator_traits<iterator>>
::value;
3671 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value &&
is_iterator_begin;
3675using iterator_t = enable_if_t<is_range<R>::value, result_of_begin<decltype(std::declval<R&>())>>;
3678using range_value_t = value_type_t<iterator_traits<iterator_t<T>>>;
3684template<
typename T,
typename =
void>
3688struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
3690template<
typename BasicJsonType,
typename CompatibleObjectType,
3692struct is_compatible_object_type_impl : std::false_type {};
3694template<
typename BasicJsonType,
typename CompatibleObjectType>
3695struct is_compatible_object_type_impl <
3696 BasicJsonType, CompatibleObjectType,
3698 is_detected<key_type_t, CompatibleObjectType>
::value >>
3703 static constexpr bool value =
3705 typename CompatibleObjectType::key_type>
::value &&
3707 typename CompatibleObjectType::mapped_type>
::value;
3710template<
typename BasicJsonType,
typename CompatibleObjectType>
3714template<
typename BasicJsonType,
typename ConstructibleObjectType,
3716struct is_constructible_object_type_impl : std::false_type {};
3718template<
typename BasicJsonType,
typename ConstructibleObjectType>
3719struct is_constructible_object_type_impl <
3720 BasicJsonType, ConstructibleObjectType,
3722 is_detected<key_type_t, ConstructibleObjectType>
::value >>
3726 static constexpr bool value =
3728 (std::is_move_assignable<ConstructibleObjectType>::value ||
3729 std::is_copy_assignable<ConstructibleObjectType>::value) &&
3731 typename object_t::key_type>
::value &&
3733 typename object_t::mapped_type,
3734 typename ConstructibleObjectType::mapped_type >
::value)) ||
3736 typename ConstructibleObjectType::mapped_type>
::value ||
3739 typename ConstructibleObjectType::mapped_type >
::value);
3742template<
typename BasicJsonType,
typename ConstructibleObjectType>
3745 ConstructibleObjectType> {};
3747template<
typename BasicJsonType,
typename CompatibleStringType>
3748struct is_compatible_string_type
3750 static constexpr auto value =
3751 is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
3754template<
typename BasicJsonType,
typename ConstructibleStringType>
3755struct is_constructible_string_type
3758#ifdef __INTEL_COMPILER
3759 using laundered_type =
decltype(std::declval<ConstructibleStringType>());
3764 static constexpr auto value =
3766 is_constructible<laundered_type, typename BasicJsonType::string_t>,
3771template<
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
3774template<
typename BasicJsonType,
typename CompatibleArrayType>
3775struct is_compatible_array_type_impl <
3776 BasicJsonType, CompatibleArrayType,
3779 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>
::value&&
3782 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>
::value >>
3784 static constexpr bool value =
3785 is_constructible<BasicJsonType,
3786 range_value_t<CompatibleArrayType>>
::value;
3789template<
typename BasicJsonType,
typename CompatibleArrayType>
3790struct is_compatible_array_type
3791 : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
3793template<
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
3794struct is_constructible_array_type_impl : std::false_type {};
3796template<
typename BasicJsonType,
typename ConstructibleArrayType>
3797struct is_constructible_array_type_impl <
3798 BasicJsonType, ConstructibleArrayType,
3800 typename BasicJsonType::value_type>
::value >>
3801 : std::true_type {};
3803template<
typename BasicJsonType,
typename ConstructibleArrayType>
3804struct is_constructible_array_type_impl <
3805 BasicJsonType, ConstructibleArrayType,
3807 typename BasicJsonType::value_type>
::value&&
3808 !is_compatible_string_type<BasicJsonType, ConstructibleArrayType>
::value&&
3809 is_default_constructible<ConstructibleArrayType>
::value&&
3810(std::is_move_assignable<ConstructibleArrayType>::value ||
3811 std::is_copy_assignable<ConstructibleArrayType>::value)&&
3812is_detected<iterator_t, ConstructibleArrayType>
::value&&
3813is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>
::value&&
3814is_detected<range_value_t, ConstructibleArrayType>
::value&&
3817!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>
::value&&
3819 detected_t<range_value_t, ConstructibleArrayType >>
::value >>
3823 static constexpr bool value =
3825 typename BasicJsonType::array_t::value_type>
::value ||
3833template<
typename BasicJsonType,
typename ConstructibleArrayType>
3837template<
typename RealIntegerType,
typename CompatibleNumberIntegerType,
3839struct is_compatible_integer_type_impl : std::false_type {};
3841template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3842struct is_compatible_integer_type_impl <
3843 RealIntegerType, CompatibleNumberIntegerType,
3845 std::is_integral<CompatibleNumberIntegerType>
::value&&
3846 !std::is_same<bool, CompatibleNumberIntegerType>
::value >>
3852 static constexpr auto value =
3854 CompatibleNumberIntegerType>
::value &&
3855 CompatibleLimits::is_integer &&
3856 RealLimits::is_signed == CompatibleLimits::is_signed;
3859template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
3862 CompatibleNumberIntegerType> {};
3864template<
typename BasicJsonType,
typename CompatibleType,
typename =
void>
3865struct is_compatible_type_impl: std::false_type {};
3867template<
typename BasicJsonType,
typename CompatibleType>
3868struct is_compatible_type_impl <
3869 BasicJsonType, CompatibleType,
3872 static constexpr bool value =
3873 has_to_json<BasicJsonType, CompatibleType>::value;
3876template<
typename BasicJsonType,
typename CompatibleType>
3877struct is_compatible_type
3878 : is_compatible_type_impl<BasicJsonType, CompatibleType> {};
3880template<
typename T1,
typename T2>
3881struct is_constructible_tuple : std::false_type {};
3883template<
typename T1,
typename... Args>
3884struct is_constructible_tuple<T1,
std::tuple<Args...>> : conjunction<is_constructible<T1, Args>...> {};
3886template<
typename BasicJsonType,
typename T>
3887struct is_json_iterator_of : std::false_type {};
3889template<
typename BasicJsonType>
3890struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::iterator> : std::true_type {};
3892template<
typename BasicJsonType>
3893struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::const_iterator> : std::true_type
3897template<
template <
typename...>
class Primary,
typename T>
3898struct is_specialization_of : std::false_type {};
3900template<
template <
typename...>
class Primary,
typename... Args>
3901struct is_specialization_of<Primary, Primary<Args...>> : std::true_type {};
3904using is_json_pointer = is_specialization_of<::nlohmann::json_pointer, uncvref_t<T>>;
3907template<
typename Compare,
typename A,
typename B,
typename =
void>
3908struct is_comparable : std::false_type {};
3910template<
typename Compare,
typename A,
typename B>
3911struct is_comparable<Compare, A, B,
void_t<
3912decltype(
std::
declval<Compare>()(std::declval<A>(), std::declval<B>())),
3913decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
3914>> : std::true_type {};
3921template<
typename Comparator,
typename ObjectKeyType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3922 bool ExcludeObjectKeyType = RequireTransparentComparator,
typename KeyType = uncvref_t<KeyTypeCVRef>>
3924 is_comparable<Comparator, ObjectKeyType, KeyTypeCVRef>::value
3925 && !(ExcludeObjectKeyType && std::is_same<KeyType,
3927 && (!RequireTransparentComparator
3928 || is_detected <detect_is_transparent, Comparator>::value)
3929 && !is_json_pointer<KeyType>::value,
3931 std::false_type >::type;
3939template<
typename BasicJsonType,
typename KeyTypeCVRef,
bool RequireTransparentComparator =
true,
3940 bool ExcludeObjectKeyType = RequireTransparentComparator,
typename KeyType = uncvref_t<KeyTypeCVRef>>
3943 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
3944 RequireTransparentComparator, ExcludeObjectKeyType>
::value
3945 && !is_json_iterator_of<BasicJsonType, KeyType>::value,
3947 std::false_type >::type;
3949template<
typename ObjectType,
typename KeyType>
3953template<
typename BasicJsonType,
typename KeyType>
3957 typename BasicJsonType::object_t, KeyType >
::value,
3959 std::false_type >::type;
3963template <
typename T>
3964struct is_ordered_map
3973 template <
typename C>
static one test(
decltype(&C::capacity) ) ;
3976 enum {
value =
sizeof(test<T>(
nullptr)) ==
sizeof(
char) };
3980template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value,
int > = 0 >
3983 return static_cast<T
>(
value);
3986template<typename T, typename U, enable_if_t<std::is_same<T, U>::value,
int> = 0>
3992template<
typename... Types>
3993using all_integral = conjunction<std::is_integral<Types>...>;
3995template<
typename... Types>
3996using all_signed = conjunction<std::is_signed<Types>...>;
3998template<
typename... Types>
3999using all_unsigned = conjunction<std::is_unsigned<Types>...>;
4002template<
typename... Types>
4003using same_sign = std::integral_constant < bool,
4006template<
typename OfType,
typename T>
4008 (std::is_signed<OfType>::value && (
sizeof(T) <
sizeof(OfType)))
4009 || (same_sign<OfType, T>::value &&
sizeof(OfType) ==
sizeof(T)) >;
4011template<
typename OfType,
typename T,
4012 bool OfTypeSigned = std::is_signed<OfType>::value,
4013 bool TSigned = std::is_signed<T>::value>
4014struct value_in_range_of_impl2;
4016template<
typename OfType,
typename T>
4017struct value_in_range_of_impl2<OfType, T, false, false>
4021 using CommonType =
typename std::common_type<OfType, T>::type;
4022 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4026template<
typename OfType,
typename T>
4027struct value_in_range_of_impl2<OfType, T, true, false>
4031 using CommonType =
typename std::common_type<OfType, T>::type;
4032 return static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4036template<
typename OfType,
typename T>
4037struct value_in_range_of_impl2<OfType, T, false, true>
4041 using CommonType =
typename std::common_type<OfType, T>::type;
4042 return val >= 0 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4047template<
typename OfType,
typename T>
4048struct value_in_range_of_impl2<OfType, T, true, true>
4052 using CommonType =
typename std::common_type<OfType, T>::type;
4053 return static_cast<CommonType
>(val) >=
static_cast<CommonType
>((std::numeric_limits<OfType>::min)())
4054 &&
static_cast<CommonType
>(val) <=
static_cast<CommonType
>((std::numeric_limits<OfType>::max)());
4058template<
typename OfType,
typename T,
4059 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
4061struct value_in_range_of_impl1;
4063template<
typename OfType,
typename T>
4064struct value_in_range_of_impl1<OfType, T, false>
4072template<
typename OfType,
typename T>
4073struct value_in_range_of_impl1<OfType, T, true>
4081template<
typename OfType,
typename T>
4084 return value_in_range_of_impl1<OfType, T>::test(val);
4088using bool_constant = std::integral_constant<bool, Value>;
4100 using TUnExt =
typename std::remove_extent<T>::type;
4101 using TUnCVExt =
typename std::remove_cv<TUnExt>::type;
4102 using TUnPtr =
typename std::remove_pointer<T>::type;
4103 using TUnCVPtr =
typename std::remove_cv<TUnPtr>::type;
4105 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
4106 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
4113struct is_c_string : bool_constant<impl::is_c_string<T>()> {};
4128 return is_detected<detect_is_transparent, T>::value;
4135struct is_transparent : bool_constant<impl::is_transparent<T>()> {};
4171template<
typename... Args>
4174template<
typename StringType,
typename... Args>
4177template<
typename... Args>
4183template<
typename... Args>
4190template<
typename StringType,
typename... Args>
4196template<
typename OutStringType>
4200template<
typename StringType,
typename Arg>
4201using string_can_append =
decltype(std::declval<StringType&>().append(std::declval < Arg && > ()));
4203template<
typename StringType,
typename Arg>
4206template<
typename StringType,
typename Arg>
4207using string_can_append_op =
decltype(std::declval<StringType&>() += std::declval < Arg && > ());
4209template<
typename StringType,
typename Arg>
4212template<
typename StringType,
typename Arg>
4213using string_can_append_iter =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().begin(), std::declval<const Arg&>().end()));
4215template<
typename StringType,
typename Arg>
4218template<
typename StringType,
typename Arg>
4219using string_can_append_data =
decltype(std::declval<StringType&>().append(std::declval<const Arg&>().data(), std::declval<const Arg&>().size()));
4221template<
typename StringType,
typename Arg>
4224template <
typename OutStringType,
typename Arg,
typename... Args,
4225 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4226 && detect_string_can_append_op<OutStringType, Arg>::value,
int > = 0 >
4227inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest);
4229template <
typename OutStringType,
typename Arg,
typename... Args,
4230 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4231 && !detect_string_can_append_op<OutStringType, Arg>::value
4232 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > = 0 >
4233inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4235template <
typename OutStringType,
typename Arg,
typename... Args,
4236 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4237 && !detect_string_can_append_op<OutStringType, Arg>::value
4238 && !detect_string_can_append_iter<OutStringType, Arg>::value
4239 && detect_string_can_append_data<OutStringType, Arg>::value,
int > = 0 >
4240inline void concat_into(OutStringType& out,
const Arg& arg, Args && ... rest);
4242template<
typename OutStringType,
typename Arg,
typename... Args,
4243 enable_if_t<detect_string_can_append<OutStringType, Arg>::value,
int> = 0>
4244inline void concat_into(OutStringType& out, Arg && arg, Args && ... rest)
4246 out.append(std::forward<Arg>(arg));
4250template <
typename OutStringType,
typename Arg,
typename... Args,
4251 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4252 && detect_string_can_append_op<OutStringType, Arg>::value,
int > >
4253inline void concat_into(OutStringType& out, Arg&& arg, Args&& ... rest)
4255 out += std::forward<Arg>(arg);
4259template <
typename OutStringType,
typename Arg,
typename... Args,
4260 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4261 && !detect_string_can_append_op<OutStringType, Arg>::value
4262 && detect_string_can_append_iter<OutStringType, Arg>::value,
int > >
4263inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4265 out.append(arg.begin(), arg.end());
4269template <
typename OutStringType,
typename Arg,
typename... Args,
4270 enable_if_t < !detect_string_can_append<OutStringType, Arg>::value
4271 && !detect_string_can_append_op<OutStringType, Arg>::value
4272 && !detect_string_can_append_iter<OutStringType, Arg>::value
4273 && detect_string_can_append_data<OutStringType, Arg>::value,
int > >
4274inline void concat_into(OutStringType& out,
const Arg& arg, Args&& ... rest)
4276 out.append(arg.data(), arg.size());
4280template<
typename OutStringType = std::string,
typename... Args>
4281inline OutStringType
concat(Args && ... args)
4304class exception :
public std::exception
4308 const char*
what() const noexcept
override
4318 exception(
int id_, const
char* what_arg) :
id(id_),
m(what_arg) {}
4320 static std::string
name(
const std::string& ename,
int id_)
4322 return concat(
"[json.exception.", ename,
'.', std::to_string(id_),
"] ");
4330 template<
typename BasicJsonType>
4334 std::vector<std::string> tokens;
4335 for (
const auto* current = leaf_element; current !=
nullptr && current->m_parent !=
nullptr; current = current->m_parent)
4337 switch (current->m_parent->type())
4341 for (
std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i)
4343 if (¤t->m_parent->m_value.array->operator[](i) == current)
4345 tokens.emplace_back(std::to_string(i));
4354 for (
const auto& element : *current->m_parent->m_value.object)
4356 if (&element.second == current)
4358 tokens.emplace_back(element.first.c_str());
4383 auto str = std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},
4384 [](
const std::string & a,
const std::string & b)
4386 return concat(a,
'/', detail::escape(b));
4388 return concat(
'(', str,
") ");
4390 static_cast<void>(leaf_element);
4397 std::runtime_error
m;
4402class parse_error :
public exception
4414 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4419 return {id_, pos.chars_read_total, w.c_str()};
4422 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4426 (byte_ != 0 ? (
concat(
" at byte ", std::to_string(byte_))) :
""),
4428 return {id_, byte_, w.c_str()};
4448 return concat(
" at line ", std::to_string(pos.lines_read + 1),
4449 ", column ", std::to_string(pos.chars_read_current_line));
4455class invalid_iterator :
public exception
4458 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4462 return {id_, w.c_str()};
4473class type_error :
public exception
4476 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4480 return {id_, w.c_str()};
4490class out_of_range :
public exception
4493 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4497 return {id_, w.c_str()};
4507class other_error :
public exception
4510 template<typename BasicJsonContext, enable_if_t<is_basic_json_context<BasicJsonContext>::value,
int> = 0>
4514 return {id_, w.c_str()};
4548template <
class T>
struct identity_tag {};
4567#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
4568#include <experimental/filesystem>
4572namespace std_fs = std::experimental::filesystem;
4575#elif JSON_HAS_FILESYSTEM
4576#include <filesystem>
4580namespace std_fs = std::filesystem;
4596template<
typename BasicJsonType>
4607template <
typename BasicJsonType,
typename ArithmeticType,
4608 enable_if_t < std::is_arithmetic<ArithmeticType>::value&&
4609 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4613 switch (
static_cast<value_t>(j))
4617 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4622 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4627 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4643template<
typename BasicJsonType>
4644inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::boolean_t& b)
4650 b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
4653template<
typename BasicJsonType>
4654inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::string_t& s)
4660 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4664 typename BasicJsonType,
typename StringType,
4666 std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value
4667 && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value
4668 && !std::is_same<typename BasicJsonType::string_t, StringType>::value
4669 && !is_json_ref<StringType>::value,
int > = 0 >
4670inline void from_json(
const BasicJsonType& j, StringType& s)
4677 s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
4680template<
typename BasicJsonType>
4681inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_float_t& val)
4686template<
typename BasicJsonType>
4687inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_unsigned_t& val)
4692template<
typename BasicJsonType>
4693inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::number_integer_t& val)
4698#if !JSON_DISABLE_ENUM_SERIALIZATION
4699template<
typename BasicJsonType,
typename EnumType,
4700 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
4701inline void from_json(
const BasicJsonType& j, EnumType& e)
4703 typename std::underlying_type<EnumType>::type val;
4705 e =
static_cast<EnumType
>(val);
4710template<
typename BasicJsonType,
typename T,
typename Allocator,
4711 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4712inline void from_json(
const BasicJsonType& j, std::forward_list<T, Allocator>& l)
4719 std::transform(j.rbegin(), j.rend(),
4720 std::front_inserter(l), [](
const BasicJsonType & i)
4722 return i.template get<T>();
4727template<
typename BasicJsonType,
typename T,
4728 enable_if_t<is_getable<BasicJsonType, T>::value,
int> = 0>
4729inline void from_json(
const BasicJsonType& j, std::valarray<T>& l)
4736 std::transform(j.begin(), j.end(), std::begin(l),
4737 [](
const BasicJsonType & elem)
4739 return elem.template get<T>();
4743template<
typename BasicJsonType,
typename T, std::
size_t N>
4744auto from_json(
const BasicJsonType& j, T (&arr)[N])
4745->
decltype(j.template get<T>(), void())
4749 arr[i] = j.at(i).template get<T>();
4753template<
typename BasicJsonType>
4754inline void from_json_array_impl(
const BasicJsonType& j,
typename BasicJsonType::array_t& arr, priority_tag<3> )
4756 arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
4759template<
typename BasicJsonType,
typename T, std::
size_t N>
4762->
decltype(j.template get<T>(), void())
4766 arr[i] = j.at(i).template get<T>();
4770template<
typename BasicJsonType,
typename ConstructibleArrayType,
4772 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4774auto from_json_array_impl(
const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> )
4776 arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
4777 j.template get<typename ConstructibleArrayType::value_type>(),
4782 ConstructibleArrayType ret;
4783 ret.reserve(j.size());
4784 std::transform(j.begin(), j.end(),
4785 std::inserter(ret, end(ret)), [](
const BasicJsonType & i)
4789 return i.template get<typename ConstructibleArrayType::value_type>();
4791 arr = std::move(ret);
4794template<
typename BasicJsonType,
typename ConstructibleArrayType,
4796 std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value,
4803 ConstructibleArrayType ret;
4805 j.begin(), j.end(), std::inserter(ret, end(ret)),
4806 [](
const BasicJsonType & i)
4810 return i.template get<typename ConstructibleArrayType::value_type>();
4812 arr = std::move(ret);
4815template <
typename BasicJsonType,
typename ConstructibleArrayType,
4817 is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value&&
4818 !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value&&
4820 !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value&&
4821 !is_basic_json<ConstructibleArrayType>::value,
4823auto from_json(
const BasicJsonType& j, ConstructibleArrayType& arr)
4825j.template get<typename ConstructibleArrayType::value_type>(),
4836template <
typename BasicJsonType,
typename T,
std::size_t... Idx >
4838 identity_tag<std::array<T,
sizeof...(Idx)>> ,
index_sequence<Idx...> )
4840 return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
4843template <
typename BasicJsonType,
typename T, std::
size_t N >
4844auto from_json(BasicJsonType&& j, identity_tag<std::array<T, N>> tag)
4855template<
typename BasicJsonType>
4856inline void from_json(
const BasicJsonType& j,
typename BasicJsonType::binary_t& bin)
4863 bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
4866template<
typename BasicJsonType,
typename ConstructibleObjectType,
4867 enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value,
int> = 0>
4868inline void from_json(
const BasicJsonType& j, ConstructibleObjectType& obj)
4875 ConstructibleObjectType ret;
4876 const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
4877 using value_type =
typename ConstructibleObjectType::value_type;
4879 inner_object->begin(), inner_object->end(),
4880 std::inserter(ret, ret.begin()),
4881 [](
typename BasicJsonType::object_t::value_type
const & p)
4883 return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
4885 obj = std::move(ret);
4892template <
typename BasicJsonType,
typename ArithmeticType,
4894 std::is_arithmetic<ArithmeticType>::value&&
4895 !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value&&
4896 !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value&&
4897 !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value&&
4898 !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
4900inline void from_json(
const BasicJsonType& j, ArithmeticType& val)
4902 switch (
static_cast<value_t>(j))
4906 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
4911 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
4916 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
4921 val =
static_cast<ArithmeticType
>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
4936template<
typename BasicJsonType,
typename... Args,
std::size_t... Idx>
4939 return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).
template get<Args>()...);
4942template <
typename BasicJsonType,
class A1,
class A2 >
4943std::pair<A1, A2>
from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> , priority_tag<0> )
4945 return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
4946 std::forward<BasicJsonType>(j).at(1).template get<A2>()};
4949template<
typename BasicJsonType,
typename A1,
typename A2>
4952 p =
from_json_tuple_impl(std::forward<BasicJsonType>(j), identity_tag<std::pair<A1, A2>> {}, priority_tag<0> {});
4955template<
typename BasicJsonType,
typename... Args>
4961template<
typename BasicJsonType,
typename... Args>
4967template<
typename BasicJsonType,
typename TupleRelated>
4968auto from_json(BasicJsonType&& j, TupleRelated&& t)
4969->
decltype(
from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {}))
4976 return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3> {});
4979template <
typename BasicJsonType,
typename Key,
typename Value,
typename Compare,
typename Allocator,
4981 typename BasicJsonType::string_t, Key >
::value >>
4982inline void from_json(
const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
4989 for (
const auto& p : j)
4995 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
4999template <
typename BasicJsonType,
typename Key,
typename Value,
typename Hash,
typename KeyEqual,
typename Allocator,
5001 typename BasicJsonType::string_t, Key >
::value >>
5002inline void from_json(
const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
5009 for (
const auto& p : j)
5015 m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
5019#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5020template<
typename BasicJsonType>
5021inline void from_json(
const BasicJsonType& j, std_fs::path& p)
5027 p = *j.template get_ptr<const typename BasicJsonType::string_t*>();
5033 template<
typename BasicJsonType,
typename T>
5035 noexcept(
noexcept(
from_json(j, std::forward<T>(val))))
5036 ->
decltype(
from_json(j, std::forward<T>(val)))
5038 return from_json(j, std::forward<T>(val));
5044#ifndef JSON_HAS_CPP_17
5053#ifndef JSON_HAS_CPP_17
5074#include <type_traits>
5111template<
typename string_type>
5115 using std::to_string;
5118template<
typename IteratorType>
class iteration_proxy_value
5126 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
5143 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5153 noexcept(
std::is_nothrow_move_constructible<IteratorType>::
value
5156 noexcept(
std::is_nothrow_move_assignable<IteratorType>::
value
5186 return anchor == o.anchor;
5192 return anchor != o.anchor;
5200 switch (
anchor.m_object->type())
5232 typename IteratorType::reference
value()
const
5239template<
typename IteratorType>
class iteration_proxy
5243 typename IteratorType::pointer
container =
nullptr;
5261 return iteration_proxy_value<IteratorType>(
container->begin());
5265 iteration_proxy_value<IteratorType>
end() const noexcept
5267 return iteration_proxy_value<IteratorType>(
container->end());
5274template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
5275auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.key())
5282template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
5283auto get(
const nlohmann::detail::iteration_proxy_value<IteratorType>& i) ->
decltype(i.value())
5298#if defined(__clang__)
5300 #pragma clang diagnostic push
5301 #pragma clang diagnostic ignored "-Wmismatched-tags"
5303template<
typename IteratorType>
5304class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>>
5305 :
public std::integral_constant<std::size_t, 2> {};
5307template<std::
size_t N,
typename IteratorType>
5308class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
5312 get<N>(std::declval <
5313 ::nlohmann::detail::iteration_proxy_value<IteratorType >> ()));
5315#if defined(__clang__)
5316 #pragma clang diagnostic pop
5322 template <
typename IteratorType>
5323 inline constexpr bool ::std::ranges::enable_borrowed_range<::nlohmann::detail::iteration_proxy<IteratorType>> =
true;
5352template<value_t>
struct external_constructor;
5357 template<
typename BasicJsonType>
5358 static void construct(BasicJsonType& j,
typename BasicJsonType::boolean_t b)
noexcept
5360 j.m_value.destroy(j.m_type);
5363 j.assert_invariant();
5370 template<
typename BasicJsonType>
5371 static void construct(BasicJsonType& j,
const typename BasicJsonType::string_t& s)
5373 j.m_value.destroy(j.m_type);
5376 j.assert_invariant();
5379 template<
typename BasicJsonType>
5380 static void construct(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5382 j.m_value.destroy(j.m_type);
5384 j.m_value = std::move(s);
5385 j.assert_invariant();
5388 template <
typename BasicJsonType,
typename CompatibleStringType,
5389 enable_if_t < !std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value,
5391 static void construct(BasicJsonType& j,
const CompatibleStringType& str)
5393 j.m_value.destroy(j.m_type);
5395 j.m_value.string = j.template create<typename BasicJsonType::string_t>(str);
5396 j.assert_invariant();
5403 template<
typename BasicJsonType>
5404 static void construct(BasicJsonType& j,
const typename BasicJsonType::binary_t& b)
5406 j.m_value.destroy(j.m_type);
5408 j.m_value =
typename BasicJsonType::binary_t(b);
5409 j.assert_invariant();
5412 template<
typename BasicJsonType>
5413 static void construct(BasicJsonType& j,
typename BasicJsonType::binary_t&& b)
5415 j.m_value.destroy(j.m_type);
5417 j.m_value =
typename BasicJsonType::binary_t(std::move(b));
5418 j.assert_invariant();
5425 template<
typename BasicJsonType>
5426 static void construct(BasicJsonType& j,
typename BasicJsonType::number_float_t val)
noexcept
5428 j.m_value.destroy(j.m_type);
5431 j.assert_invariant();
5438 template<
typename BasicJsonType>
5439 static void construct(BasicJsonType& j,
typename BasicJsonType::number_unsigned_t val)
noexcept
5441 j.m_value.destroy(j.m_type);
5444 j.assert_invariant();
5451 template<
typename BasicJsonType>
5452 static void construct(BasicJsonType& j,
typename BasicJsonType::number_integer_t val)
noexcept
5454 j.m_value.destroy(j.m_type);
5457 j.assert_invariant();
5464 template<
typename BasicJsonType>
5465 static void construct(BasicJsonType& j,
const typename BasicJsonType::array_t& arr)
5467 j.m_value.destroy(j.m_type);
5471 j.assert_invariant();
5474 template<
typename BasicJsonType>
5475 static void construct(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5477 j.m_value.destroy(j.m_type);
5479 j.m_value = std::move(arr);
5481 j.assert_invariant();
5484 template <
typename BasicJsonType,
typename CompatibleArrayType,
5485 enable_if_t < !std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value,
5487 static void construct(BasicJsonType& j,
const CompatibleArrayType& arr)
5492 j.m_value.destroy(j.m_type);
5494 j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr));
5496 j.assert_invariant();
5499 template<
typename BasicJsonType>
5500 static void construct(BasicJsonType& j,
const std::vector<bool>& arr)
5502 j.m_value.destroy(j.m_type);
5505 j.m_value.array->reserve(arr.size());
5506 for (
const bool x : arr)
5508 j.m_value.array->push_back(x);
5509 j.set_parent(j.m_value.array->back());
5511 j.assert_invariant();
5514 template<
typename BasicJsonType,
typename T,
5515 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5516 static void construct(BasicJsonType& j,
const std::valarray<T>& arr)
5518 j.m_value.destroy(j.m_type);
5521 j.m_value.array->resize(arr.size());
5524 std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin());
5527 j.assert_invariant();
5534 template<
typename BasicJsonType>
5535 static void construct(BasicJsonType& j,
const typename BasicJsonType::object_t& obj)
5537 j.m_value.destroy(j.m_type);
5541 j.assert_invariant();
5544 template<
typename BasicJsonType>
5545 static void construct(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5547 j.m_value.destroy(j.m_type);
5549 j.m_value = std::move(obj);
5551 j.assert_invariant();
5554 template <
typename BasicJsonType,
typename CompatibleObjectType,
5555 enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value,
int > = 0 >
5556 static void construct(BasicJsonType& j,
const CompatibleObjectType& obj)
5561 j.m_value.destroy(j.m_type);
5563 j.m_value.object = j.template create<typename BasicJsonType::object_t>(begin(obj), end(obj));
5565 j.assert_invariant();
5573template<
typename BasicJsonType,
typename T,
5574 enable_if_t<std::is_same<T, typename BasicJsonType::boolean_t>::value,
int> = 0>
5575inline void to_json(BasicJsonType& j, T b)
noexcept
5577 external_constructor<value_t::boolean>::construct(j, b);
5580template <
typename BasicJsonType,
typename BoolRef,
5582 ((std::is_same<std::vector<bool>::reference, BoolRef>
::value
5583 && !std::is_same <std::vector<bool>::reference,
typename BasicJsonType::boolean_t&>
::value)
5584 || (std::is_same<std::vector<bool>::const_reference, BoolRef>
::value
5586 typename BasicJsonType::boolean_t >
::value))
5587 && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
int > = 0 >
5588inline void to_json(BasicJsonType& j,
const BoolRef& b)
noexcept
5590 external_constructor<value_t::boolean>::construct(j,
static_cast<typename BasicJsonType::boolean_t
>(b));
5593template<
typename BasicJsonType,
typename CompatibleString,
5594 enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value,
int> = 0>
5595inline void to_json(BasicJsonType& j,
const CompatibleString& s)
5597 external_constructor<value_t::string>::construct(j, s);
5600template<
typename BasicJsonType>
5601inline void to_json(BasicJsonType& j,
typename BasicJsonType::string_t&& s)
5603 external_constructor<value_t::string>::construct(j, std::move(s));
5606template<
typename BasicJsonType,
typename FloatType,
5607 enable_if_t<std::is_floating_point<FloatType>::value,
int> = 0>
5608inline void to_json(BasicJsonType& j, FloatType val)
noexcept
5610 external_constructor<value_t::number_float>::construct(j,
static_cast<typename BasicJsonType::number_float_t
>(val));
5613template<
typename BasicJsonType,
typename CompatibleNumberUnsignedType,
5614 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value,
int> = 0>
5615inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val)
noexcept
5617 external_constructor<value_t::number_unsigned>::construct(j,
static_cast<typename BasicJsonType::number_unsigned_t
>(val));
5620template<
typename BasicJsonType,
typename CompatibleNumberIntegerType,
5621 enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value,
int> = 0>
5622inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val)
noexcept
5624 external_constructor<value_t::number_integer>::construct(j,
static_cast<typename BasicJsonType::number_integer_t
>(val));
5627#if !JSON_DISABLE_ENUM_SERIALIZATION
5628template<
typename BasicJsonType,
typename EnumType,
5629 enable_if_t<std::is_enum<EnumType>::value,
int> = 0>
5630inline void to_json(BasicJsonType& j, EnumType e)
noexcept
5632 using underlying_type =
typename std::underlying_type<EnumType>::type;
5633 external_constructor<value_t::number_integer>::construct(j,
static_cast<underlying_type
>(e));
5637template<
typename BasicJsonType>
5638inline void to_json(BasicJsonType& j,
const std::vector<bool>& e)
5640 external_constructor<value_t::array>::construct(j, e);
5643template <
typename BasicJsonType,
typename CompatibleArrayType,
5644 enable_if_t < is_compatible_array_type<BasicJsonType,
5646 !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value&&
5648 !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value&&
5649 !is_basic_json<CompatibleArrayType>::value,
5651inline void to_json(BasicJsonType& j,
const CompatibleArrayType& arr)
5653 external_constructor<value_t::array>::construct(j, arr);
5656template<
typename BasicJsonType>
5657inline void to_json(BasicJsonType& j,
const typename BasicJsonType::binary_t& bin)
5659 external_constructor<value_t::binary>::construct(j, bin);
5662template<
typename BasicJsonType,
typename T,
5663 enable_if_t<std::is_convertible<T, BasicJsonType>::value,
int> = 0>
5664inline void to_json(BasicJsonType& j,
const std::valarray<T>& arr)
5666 external_constructor<value_t::array>::construct(j, std::move(arr));
5669template<
typename BasicJsonType>
5670inline void to_json(BasicJsonType& j,
typename BasicJsonType::array_t&& arr)
5672 external_constructor<value_t::array>::construct(j, std::move(arr));
5675template <
typename BasicJsonType,
typename CompatibleObjectType,
5676 enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value,
int > = 0 >
5677inline void to_json(BasicJsonType& j,
const CompatibleObjectType& obj)
5679 external_constructor<value_t::object>::construct(j, obj);
5682template<
typename BasicJsonType>
5683inline void to_json(BasicJsonType& j,
typename BasicJsonType::object_t&& obj)
5685 external_constructor<value_t::object>::construct(j, std::move(obj));
5689 typename BasicJsonType,
typename T,
std::size_t N,
5690 enable_if_t < !std::is_constructible<
typename BasicJsonType::string_t,
5693inline void to_json(BasicJsonType& j,
const T(&arr)[N])
5695 external_constructor<value_t::array>::construct(j, arr);
5698template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible<BasicJsonType, T1>::value&& std::is_constructible<BasicJsonType, T2>::value,
int > = 0 >
5699inline void to_json(BasicJsonType& j,
const std::pair<T1, T2>& p)
5701 j = { p.first, p.second };
5705template<
typename BasicJsonType,
typename T,
5706 enable_if_t<std::is_same<T, iteration_proxy_value<typename BasicJsonType::iterator>>
::value,
int> = 0>
5707inline void to_json(BasicJsonType& j,
const T& b)
5709 j = { {b.key(), b.value()} };
5712template<
typename BasicJsonType,
typename Tuple,
std::size_t... Idx>
5713inline void to_json_tuple_impl(BasicJsonType& j,
const Tuple& t, index_sequence<Idx...> )
5715 j = { std::get<Idx>(t)... };
5718template<typename BasicJsonType, typename T, enable_if_t<is_constructible_tuple<BasicJsonType, T>::value,
int > = 0>
5719inline void to_json(BasicJsonType& j,
const T& t)
5724#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
5725template<
typename BasicJsonType>
5726inline void to_json(BasicJsonType& j,
const std_fs::path& p)
5734 template<
typename BasicJsonType,
typename T>
5735 auto operator()(BasicJsonType& j, T&& val)
const noexcept(
noexcept(
to_json(j, std::forward<T>(val))))
5736 ->
decltype(
to_json(j, std::forward<T>(val)), void())
5738 return to_json(j, std::forward<T>(val));
5743#ifndef JSON_HAS_CPP_17
5752#ifndef JSON_HAS_CPP_17
5764template<
typename ValueType,
typename>
5769 template<
typename BasicJsonType,
typename TargetType = ValueType>
5770 static auto from_json(BasicJsonType && j, TargetType& val)
noexcept(
5771 noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
5772 ->
decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
5774 ::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
5779 template<
typename BasicJsonType,
typename TargetType = ValueType>
5789 template<
typename BasicJsonType,
typename TargetType = ValueType>
5790 static auto to_json(BasicJsonType& j, TargetType && val)
noexcept(
5791 noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
5792 ->
decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
5794 ::nlohmann::to_json(j, std::forward<TargetType>(val));
5822template<
typename BinaryType>
5866 return !(rhs == *
this);
5925#include <functional>
5939 seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
5954template<
typename BasicJsonType>
5957 using string_t =
typename BasicJsonType::string_t;
5958 using number_integer_t =
typename BasicJsonType::number_integer_t;
5959 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
5960 using number_float_t =
typename BasicJsonType::number_float_t;
5962 const auto type =
static_cast<std::size_t>(j.type());
5965 case BasicJsonType::value_t::null:
5966 case BasicJsonType::value_t::discarded:
5971 case BasicJsonType::value_t::object:
5973 auto seed =
combine(type, j.size());
5974 for (
const auto& element : j.items())
5976 const auto h = std::hash<string_t> {}(element.key());
5983 case BasicJsonType::value_t::array:
5985 auto seed =
combine(type, j.size());
5986 for (
const auto& element : j)
5993 case BasicJsonType::value_t::string:
5995 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
5999 case BasicJsonType::value_t::boolean:
6001 const auto h = std::hash<bool> {}(j.template get<bool>());
6005 case BasicJsonType::value_t::number_integer:
6007 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
6011 case BasicJsonType::value_t::number_unsigned:
6013 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
6017 case BasicJsonType::value_t::number_float:
6019 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
6023 case BasicJsonType::value_t::binary:
6025 auto seed =
combine(type, j.get_binary().size());
6026 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
6029 for (
const auto byte : j.get_binary())
6031 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
6089#include <type_traits>
6118class file_input_adapter
6139 return std::fgetc(
m_file);
6157class input_stream_adapter
6168 is->clear(
is->rdstate() & std::ios::eofbit);
6173 :
is(&i),
sb(i.rdbuf())
6182 :
is(rhs.is),
sb(rhs.sb)
6193 auto res =
sb->sbumpc();
6197 is->clear(
is->rdstate() | std::ios::eofbit);
6205 std::streambuf*
sb =
nullptr;
6211template<
typename IteratorType>
6212class iterator_input_adapter
6215 using char_type =
typename std::iterator_traits<IteratorType>::value_type;
6237 template<
typename BaseInputAdapter,
size_t T>
6247template<
typename BaseInputAdapter,
size_t T>
6248struct wide_string_input_helper;
6250template<
typename BaseInputAdapter>
6251struct wide_string_input_helper<BaseInputAdapter, 4>
6256 size_t& utf8_bytes_index,
6257 size_t& utf8_bytes_filled)
6259 utf8_bytes_index = 0;
6264 utf8_bytes_filled = 1;
6269 const auto wc = input.get_character();
6275 utf8_bytes_filled = 1;
6277 else if (wc <= 0x7FF)
6281 utf8_bytes_filled = 2;
6283 else if (wc <= 0xFFFF)
6288 utf8_bytes_filled = 3;
6290 else if (wc <= 0x10FFFF)
6296 utf8_bytes_filled = 4;
6302 utf8_bytes_filled = 1;
6308template<
typename BaseInputAdapter>
6309struct wide_string_input_helper<BaseInputAdapter, 2>
6314 size_t& utf8_bytes_index,
6315 size_t& utf8_bytes_filled)
6317 utf8_bytes_index = 0;
6322 utf8_bytes_filled = 1;
6327 const auto wc = input.get_character();
6333 utf8_bytes_filled = 1;
6335 else if (wc <= 0x7FF)
6339 utf8_bytes_filled = 2;
6341 else if (0xD800 > wc || wc >= 0xE000)
6346 utf8_bytes_filled = 3;
6352 const auto wc2 =
static_cast<unsigned int>(input.get_character());
6353 const auto charcode = 0x10000u + (((
static_cast<unsigned int>(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu));
6358 utf8_bytes_filled = 4;
6363 utf8_bytes_filled = 1;
6371template<
typename BaseInputAdapter,
typename W
ideCharType>
6372class wide_string_input_adapter
6385 fill_buffer<sizeof(WideCharType)>();
6407 std::array<std::char_traits<char>::int_type, 4>
utf8_bytes = {{0, 0, 0, 0}};
6416template<
typename IteratorType,
typename Enable =
void>
6417struct iterator_input_adapter_factory
6420 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6425 return adapter_type(std::move(first), std::move(last));
6430struct is_iterator_of_multibyte
6439template<
typename IteratorType>
6440struct iterator_input_adapter_factory<IteratorType,
enable_if_t<is_iterator_of_multibyte<IteratorType>::
value>>
6443 using char_type =
typename std::iterator_traits<iterator_type>::value_type;
6445 using adapter_type = wide_string_input_adapter<base_adapter_type, char_type>;
6454template<
typename IteratorType>
6457 using factory_type = iterator_input_adapter_factory<IteratorType>;
6458 return factory_type::create(first, last);
6465namespace container_input_adapter_factory_impl
6471template<
typename ContainerType,
typename Enable =
void>
6472struct container_input_adapter_factory {};
6474template<
typename ContainerType>
6475struct container_input_adapter_factory< ContainerType,
6476 void_t<decltype(begin(
std::
declval<ContainerType>()), end(std::declval<ContainerType>()))>>
6488template<
typename ContainerType>
6489typename container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::adapter_type
input_adapter(
const ContainerType& container)
6491 return container_input_adapter_factory_impl::container_input_adapter_factory<ContainerType>::create(container);
6498 return file_input_adapter(file);
6503 return input_stream_adapter(stream);
6508 return input_stream_adapter(stream);
6515template <
typename CharT,
6516 typename std::enable_if <
6517 std::is_pointer<CharT>::value&&
6518 !std::is_array<CharT>::value&&
6519 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6520 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6524 auto length = std::strlen(
reinterpret_cast<const char*
>(b));
6525 const auto* ptr =
reinterpret_cast<const char*
>(b);
6529template<
typename T, std::
size_t N>
6538class span_input_adapter
6541 template <
typename CharT,
6542 typename std::enable_if <
6543 std::is_pointer<CharT>::value&&
6544 std::is_integral<typename std::remove_pointer<CharT>::type>
::value&&
6545 sizeof(
typename std::remove_pointer<CharT>::type) == 1,
6548 : ia(
reinterpret_cast<const char*
>(b),
reinterpret_cast<const char*
>(b) + l) {}
6550 template<
class IteratorType,
6551 typename std::enable_if<
6552 std::is_same<typename iterator_traits<IteratorType>::iterator_category, std::random_access_iterator_tag>
::value,
6559 return std::move(ia);
6602template<
typename BasicJsonType>
6706 const std::string& last_token,
6733template<
typename BasicJsonType>
6734class json_sax_dom_parser
6749 : root(r), allow_exceptions(allow_exceptions_)
6761 handle_value(
nullptr);
6797 handle_value(std::move(val));
6803 ref_stack.push_back(handle_value(BasicJsonType::value_t::object));
6807 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
6819 object_element = &(ref_stack.back()->m_value.object->operator[](val));
6828 ref_stack.back()->set_parents();
6829 ref_stack.pop_back();
6835 ref_stack.push_back(handle_value(BasicJsonType::value_t::array));
6839 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
6850 ref_stack.back()->set_parents();
6851 ref_stack.pop_back();
6855 template<
class Exception>
6857 const Exception& ex)
6860 static_cast<void>(ex);
6861 if (allow_exceptions)
6880 template<
typename Value>
6884 if (ref_stack.empty())
6886 root = BasicJsonType(std::forward<Value>(v));
6890 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
6892 if (ref_stack.back()->is_array())
6894 ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
6895 return &(ref_stack.back()->m_value.array->back());
6900 *object_element = BasicJsonType(std::forward<Value>(v));
6901 return object_element;
6905 BasicJsonType& root;
6907 std::vector<BasicJsonType*> ref_stack {};
6909 BasicJsonType* object_element =
nullptr;
6911 bool errored =
false;
6913 const bool allow_exceptions =
true;
6916template<
typename BasicJsonType>
6917class json_sax_dom_callback_parser
6930 const bool allow_exceptions_ =
true)
6931 : root(r), callback(cb), allow_exceptions(allow_exceptions_)
6933 keep_stack.push_back(
true);
6945 handle_value(
nullptr);
6981 handle_value(std::move(val));
6988 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::object_start,
discarded);
6989 keep_stack.push_back(keep);
6991 auto val = handle_value(BasicJsonType::value_t::object,
true);
6992 ref_stack.push_back(val.second);
6997 JSON_THROW(out_of_range::create(408,
concat(
"excessive object size: ", std::to_string(len)), ref_stack.back()));
7005 BasicJsonType k = BasicJsonType(val);
7008 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::key, k);
7009 key_keep_stack.push_back(keep);
7012 if (keep && ref_stack.back())
7014 object_element = &(ref_stack.back()->m_value.object->operator[](val) =
discarded);
7022 if (ref_stack.back())
7024 if (!callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
7031 ref_stack.back()->set_parents();
7037 ref_stack.pop_back();
7038 keep_stack.pop_back();
7040 if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured())
7043 for (
auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
7045 if (it->is_discarded())
7047 ref_stack.back()->erase(it);
7058 const bool keep = callback(
static_cast<int>(ref_stack.size()), parse_event_t::array_start,
discarded);
7059 keep_stack.push_back(keep);
7061 auto val = handle_value(BasicJsonType::value_t::array,
true);
7062 ref_stack.push_back(val.second);
7067 JSON_THROW(out_of_range::create(408,
concat(
"excessive array size: ", std::to_string(len)), ref_stack.back()));
7077 if (ref_stack.back())
7079 keep = callback(
static_cast<int>(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back());
7082 ref_stack.back()->set_parents();
7093 ref_stack.pop_back();
7094 keep_stack.pop_back();
7097 if (!keep && !ref_stack.empty() && ref_stack.back()->is_array())
7099 ref_stack.back()->m_value.array->pop_back();
7105 template<
class Exception>
7107 const Exception& ex)
7110 static_cast<void>(ex);
7111 if (allow_exceptions)
7139 template<
typename Value>
7140 std::pair<bool, BasicJsonType*>
handle_value(Value&& v,
const bool skip_callback =
false)
7146 if (!keep_stack.back())
7148 return {
false,
nullptr};
7152 auto value = BasicJsonType(std::forward<Value>(v));
7155 const bool keep = skip_callback || callback(
static_cast<int>(ref_stack.size()), parse_event_t::value,
value);
7160 return {
false,
nullptr};
7163 if (ref_stack.empty())
7165 root = std::move(
value);
7166 return {
true, &root};
7171 if (!ref_stack.back())
7173 return {
false,
nullptr};
7177 JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object());
7180 if (ref_stack.back()->is_array())
7182 ref_stack.back()->m_value.array->emplace_back(std::move(
value));
7183 return {
true, &(ref_stack.back()->m_value.array->back())};
7190 const bool store_element = key_keep_stack.back();
7191 key_keep_stack.pop_back();
7195 return {
false,
nullptr};
7199 *object_element = std::move(
value);
7200 return {
true, object_element};
7204 BasicJsonType& root;
7206 std::vector<BasicJsonType*> ref_stack {};
7208 std::vector<bool> keep_stack {};
7210 std::vector<bool> key_keep_stack {};
7212 BasicJsonType* object_element =
nullptr;
7214 bool errored =
false;
7218 const bool allow_exceptions =
true;
7220 BasicJsonType
discarded = BasicJsonType::value_t::discarded;
7223template<
typename BasicJsonType>
7224class json_sax_acceptor
7318#include <initializer_list>
7338template<
typename BasicJsonType>
7371 case token_type::uninitialized:
7372 return "<uninitialized>";
7373 case token_type::literal_true:
7374 return "true literal";
7375 case token_type::literal_false:
7376 return "false literal";
7377 case token_type::literal_null:
7378 return "null literal";
7379 case token_type::value_string:
7380 return "string literal";
7381 case token_type::value_unsigned:
7382 case token_type::value_integer:
7383 case token_type::value_float:
7384 return "number literal";
7385 case token_type::begin_array:
7387 case token_type::begin_object:
7389 case token_type::end_array:
7391 case token_type::end_object:
7393 case token_type::name_separator:
7395 case token_type::value_separator:
7397 case token_type::parse_error:
7398 return "<parse error>";
7399 case token_type::end_of_input:
7400 return "end of input";
7401 case token_type::literal_or_value:
7402 return "'[', '{', or a literal";
7405 return "unknown token";
7415template<
typename BasicJsonType,
typename InputAdapterType>
7416class lexer :
public lexer_base<BasicJsonType>
7428 explicit lexer(InputAdapterType&& adapter,
bool ignore_comments_ =
false) noexcept
7429 : ia(
std::move(adapter))
7430 , ignore_comments(ignore_comments_)
7431 , decimal_point_char(static_cast<
char_int_type>(get_decimal_point()))
7450 const auto* loc = localeconv();
7452 return (loc->decimal_point ==
nullptr) ?
'.' : *(loc->decimal_point);
7480 const auto factors = { 12u, 8u, 4u, 0u };
7481 for (
const auto factor : factors)
7485 if (current >=
'0' && current <=
'9')
7487 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x30u) << factor);
7489 else if (current >=
'A' && current <=
'F')
7491 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x37u) << factor);
7493 else if (current >=
'a' && current <=
'f')
7495 codepoint +=
static_cast<int>((
static_cast<unsigned int>(current) - 0x57u) << factor);
7503 JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF);
7524 JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6);
7527 for (
auto range = ranges.begin(); range != ranges.end(); ++range)
7536 error_message =
"invalid string: ill-formed UTF-8 byte";
7575 error_message =
"invalid string: missing closing quote";
7576 return token_type::parse_error;
7582 return token_type::value_string;
7626 const int codepoint1 = get_codepoint();
7627 int codepoint = codepoint1;
7631 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7632 return token_type::parse_error;
7636 if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF)
7641 const int codepoint2 = get_codepoint();
7645 error_message =
"invalid string: '\\u' must be followed by 4 hex digits";
7646 return token_type::parse_error;
7653 codepoint =
static_cast<int>(
7655 (
static_cast<unsigned int>(codepoint1) << 10u)
7657 +
static_cast<unsigned int>(codepoint2)
7665 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7666 return token_type::parse_error;
7671 error_message =
"invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF";
7672 return token_type::parse_error;
7679 error_message =
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF";
7680 return token_type::parse_error;
7685 JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
7688 if (codepoint < 0x80)
7693 else if (codepoint <= 0x7FF)
7696 add(
static_cast<char_int_type>(0xC0u | (
static_cast<unsigned int>(codepoint) >> 6u)));
7697 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7699 else if (codepoint <= 0xFFFF)
7702 add(
static_cast<char_int_type>(0xE0u | (
static_cast<unsigned int>(codepoint) >> 12u)));
7703 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7704 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7709 add(
static_cast<char_int_type>(0xF0u | (
static_cast<unsigned int>(codepoint) >> 18u)));
7710 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu)));
7711 add(
static_cast<char_int_type>(0x80u | ((
static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu)));
7712 add(
static_cast<char_int_type>(0x80u | (
static_cast<unsigned int>(codepoint) & 0x3Fu)));
7720 error_message =
"invalid string: forbidden character after backslash";
7721 return token_type::parse_error;
7730 error_message =
"invalid string: control character U+0000 (NUL) must be escaped to \\u0000";
7731 return token_type::parse_error;
7736 error_message =
"invalid string: control character U+0001 (SOH) must be escaped to \\u0001";
7737 return token_type::parse_error;
7742 error_message =
"invalid string: control character U+0002 (STX) must be escaped to \\u0002";
7743 return token_type::parse_error;
7748 error_message =
"invalid string: control character U+0003 (ETX) must be escaped to \\u0003";
7749 return token_type::parse_error;
7754 error_message =
"invalid string: control character U+0004 (EOT) must be escaped to \\u0004";
7755 return token_type::parse_error;
7760 error_message =
"invalid string: control character U+0005 (ENQ) must be escaped to \\u0005";
7761 return token_type::parse_error;
7766 error_message =
"invalid string: control character U+0006 (ACK) must be escaped to \\u0006";
7767 return token_type::parse_error;
7772 error_message =
"invalid string: control character U+0007 (BEL) must be escaped to \\u0007";
7773 return token_type::parse_error;
7778 error_message =
"invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b";
7779 return token_type::parse_error;
7784 error_message =
"invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t";
7785 return token_type::parse_error;
7790 error_message =
"invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n";
7791 return token_type::parse_error;
7796 error_message =
"invalid string: control character U+000B (VT) must be escaped to \\u000B";
7797 return token_type::parse_error;
7802 error_message =
"invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f";
7803 return token_type::parse_error;
7808 error_message =
"invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r";
7809 return token_type::parse_error;
7814 error_message =
"invalid string: control character U+000E (SO) must be escaped to \\u000E";
7815 return token_type::parse_error;
7820 error_message =
"invalid string: control character U+000F (SI) must be escaped to \\u000F";
7821 return token_type::parse_error;
7826 error_message =
"invalid string: control character U+0010 (DLE) must be escaped to \\u0010";
7827 return token_type::parse_error;
7832 error_message =
"invalid string: control character U+0011 (DC1) must be escaped to \\u0011";
7833 return token_type::parse_error;
7838 error_message =
"invalid string: control character U+0012 (DC2) must be escaped to \\u0012";
7839 return token_type::parse_error;
7844 error_message =
"invalid string: control character U+0013 (DC3) must be escaped to \\u0013";
7845 return token_type::parse_error;
7850 error_message =
"invalid string: control character U+0014 (DC4) must be escaped to \\u0014";
7851 return token_type::parse_error;
7856 error_message =
"invalid string: control character U+0015 (NAK) must be escaped to \\u0015";
7857 return token_type::parse_error;
7862 error_message =
"invalid string: control character U+0016 (SYN) must be escaped to \\u0016";
7863 return token_type::parse_error;
7868 error_message =
"invalid string: control character U+0017 (ETB) must be escaped to \\u0017";
7869 return token_type::parse_error;
7874 error_message =
"invalid string: control character U+0018 (CAN) must be escaped to \\u0018";
7875 return token_type::parse_error;
7880 error_message =
"invalid string: control character U+0019 (EM) must be escaped to \\u0019";
7881 return token_type::parse_error;
7886 error_message =
"invalid string: control character U+001A (SUB) must be escaped to \\u001A";
7887 return token_type::parse_error;
7892 error_message =
"invalid string: control character U+001B (ESC) must be escaped to \\u001B";
7893 return token_type::parse_error;
7898 error_message =
"invalid string: control character U+001C (FS) must be escaped to \\u001C";
7899 return token_type::parse_error;
7904 error_message =
"invalid string: control character U+001D (GS) must be escaped to \\u001D";
7905 return token_type::parse_error;
7910 error_message =
"invalid string: control character U+001E (RS) must be escaped to \\u001E";
7911 return token_type::parse_error;
7916 error_message =
"invalid string: control character U+001F (US) must be escaped to \\u001F";
7917 return token_type::parse_error;
8054 return token_type::parse_error;
8064 return token_type::parse_error;
8088 return token_type::parse_error;
8098 return token_type::parse_error;
8108 return token_type::parse_error;
8120 return token_type::parse_error;
8130 return token_type::parse_error;
8138 error_message =
"invalid string: ill-formed UTF-8 byte";
8139 return token_type::parse_error;
8182 error_message =
"invalid comment; missing closing '*/'";
8210 error_message =
"invalid comment; expecting '/' or '*' after '/'";
8217 static
void strtof(
float& f, const
char* str,
char** endptr) noexcept
8219 f = std::strtof(str, endptr);
8223 static
void strtof(
double& f, const
char* str,
char** endptr) noexcept
8225 f = std::strtod(str, endptr);
8229 static
void strtof(
long double& f, const
char* str,
char** endptr) noexcept
8231 f = std::strtold(str, endptr);
8281 token_type number_type = token_type::value_unsigned;
8289 goto scan_number_minus;
8295 goto scan_number_zero;
8309 goto scan_number_any1;
8319 number_type = token_type::value_integer;
8325 goto scan_number_zero;
8339 goto scan_number_any1;
8344 error_message =
"invalid number; expected digit after '-'";
8345 return token_type::parse_error;
8355 add(decimal_point_char);
8356 goto scan_number_decimal1;
8363 goto scan_number_exponent;
8367 goto scan_number_done;
8386 goto scan_number_any1;
8391 add(decimal_point_char);
8392 goto scan_number_decimal1;
8399 goto scan_number_exponent;
8403 goto scan_number_done;
8406scan_number_decimal1:
8408 number_type = token_type::value_float;
8423 goto scan_number_decimal2;
8428 error_message =
"invalid number; expected digit after '.'";
8429 return token_type::parse_error;
8433scan_number_decimal2:
8449 goto scan_number_decimal2;
8456 goto scan_number_exponent;
8460 goto scan_number_done;
8463scan_number_exponent:
8465 number_type = token_type::value_float;
8472 goto scan_number_sign;
8487 goto scan_number_any2;
8493 "invalid number; expected '+', '-', or digit after exponent";
8494 return token_type::parse_error;
8514 goto scan_number_any2;
8519 error_message =
"invalid number; expected digit after exponent sign";
8520 return token_type::parse_error;
8540 goto scan_number_any2;
8544 goto scan_number_done;
8552 char* endptr =
nullptr;
8556 if (number_type == token_type::value_unsigned)
8558 const auto x = std::strtoull(token_buffer.data(), &endptr, 10);
8561 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8566 if (value_unsigned == x)
8568 return token_type::value_unsigned;
8572 else if (number_type == token_type::value_integer)
8574 const auto x = std::strtoll(token_buffer.data(), &endptr, 10);
8577 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8582 if (value_integer == x)
8584 return token_type::value_integer;
8591 strtof(value_float, token_buffer.data(), &endptr);
8594 JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size());
8596 return token_type::value_float;
8613 error_message =
"invalid literal";
8614 return token_type::parse_error;
8627 token_buffer.clear();
8628 token_string.clear();
8644 ++position.chars_read_total;
8645 ++position.chars_read_current_line;
8654 current = ia.get_character();
8662 if (current ==
'\n')
8664 ++position.lines_read;
8665 position.chars_read_current_line = 0;
8683 --position.chars_read_total;
8686 if (position.chars_read_current_line == 0)
8688 if (position.lines_read > 0)
8690 --position.lines_read;
8695 --position.chars_read_current_line;
8701 token_string.pop_back();
8708 token_buffer.push_back(
static_cast<typename string_t::value_type
>(c));
8719 return value_integer;
8725 return value_unsigned;
8737 return token_buffer;
8757 for (
const auto c : token_string)
8759 if (
static_cast<unsigned char>(c) <=
'\x1F')
8762 std::array<char, 9> cs{{}};
8763 static_cast<void>((std::snprintf)(cs.data(), cs.size(),
"<U+%.4X>",
static_cast<unsigned char>(c)));
8764 result += cs.data();
8769 result.push_back(
static_cast<std::string::value_type
>(c));
8780 return error_message;
8796 return get() == 0xBB && get() == 0xBF;
8811 while (current ==
' ' || current ==
'\t' || current ==
'\n' || current ==
'\r');
8817 if (position.chars_read_total == 0 && !skip_bom())
8819 error_message =
"invalid BOM; must be 0xEF 0xBB 0xBF if given";
8820 return token_type::parse_error;
8827 while (ignore_comments && current ==
'/')
8829 if (!scan_comment())
8831 return token_type::parse_error;
8842 return token_type::begin_array;
8844 return token_type::end_array;
8846 return token_type::begin_object;
8848 return token_type::end_object;
8850 return token_type::name_separator;
8852 return token_type::value_separator;
8858 return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true);
8863 return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false);
8868 return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null);
8873 return scan_string();
8887 return scan_number();
8893 return token_type::end_of_input;
8897 error_message =
"invalid literal";
8898 return token_type::parse_error;
8904 InputAdapterType ia;
8907 const bool ignore_comments =
false;
8913 bool next_unget =
false;
8919 std::vector<char_type> token_string {};
8922 string_t token_buffer {};
8925 const char* error_message =
"";
8928 number_integer_t value_integer = 0;
8929 number_unsigned_t value_unsigned = 0;
8930 number_float_t value_float = 0;
8933 const char_int_type decimal_point_char =
'.';
8972 decltype(std::declval<T&>().boolean(std::declval<bool>()));
8974template<
typename T,
typename Integer>
8976 decltype(std::declval<T&>().number_integer(std::declval<Integer>()));
8978template<
typename T,
typename Un
signed>
8980 decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()));
8982template<
typename T,
typename Float,
typename String>
8984 std::declval<Float>(), std::declval<const String&>()));
8986template<
typename T,
typename String>
8988 decltype(std::declval<T&>().string(std::declval<String&>()));
8990template<
typename T,
typename Binary>
8992 decltype(std::declval<T&>().binary(std::declval<Binary&>()));
8996 decltype(std::declval<T&>().start_object(std::declval<std::size_t>()));
8998template<
typename T,
typename String>
9000 decltype(std::declval<T&>().key(std::declval<String&>()));
9007 decltype(std::declval<T&>().start_array(std::declval<std::size_t>()));
9012template<
typename T,
typename Exception>
9014 std::declval<std::size_t>(), std::declval<const std::string&>(),
9015 std::declval<const Exception&>()));
9017template<
typename SAX,
typename BasicJsonType>
9021 static_assert(is_basic_json<BasicJsonType>::value,
9022 "BasicJsonType must be of type basic_json<...>");
9032 static constexpr bool value =
9048template<
typename SAX,
typename BasicJsonType>
9053 "BasicJsonType must be of type basic_json<...>");
9064 "Missing/invalid function: bool null()");
9066 "Missing/invalid function: bool boolean(bool)");
9068 "Missing/invalid function: bool boolean(bool)");
9072 "Missing/invalid function: bool number_integer(number_integer_t)");
9076 "Missing/invalid function: bool number_unsigned(number_unsigned_t)");
9079 "Missing/invalid function: bool number_float(number_float_t, const string_t&)");
9082 "Missing/invalid function: bool string(string_t&)");
9085 "Missing/invalid function: bool binary(binary_t&)");
9087 "Missing/invalid function: bool start_object(std::size_t)");
9089 "Missing/invalid function: bool key(string_t&)");
9091 "Missing/invalid function: bool end_object()");
9093 "Missing/invalid function: bool start_array(std::size_t)");
9095 "Missing/invalid function: bool end_array()");
9098 "Missing/invalid function: bool parse_error(std::size_t, const "
9099 "std::string&, const exception&)");
9133 return *
reinterpret_cast<char*
>(&num) == 1;
9144template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX = json_sax_dom_parser<BasicJsonType>>
9162 explicit binary_reader(InputAdapterType&& adapter,
const input_format_t format = input_format_t::json) noexcept : ia(std::move(adapter)), input_format(format)
9185 const
bool strict = true,
9189 bool result =
false;
9193 case input_format_t::bson:
9194 result = parse_bson_internal();
9197 case input_format_t::cbor:
9198 result = parse_cbor_internal(
true, tag_handler);
9201 case input_format_t::msgpack:
9202 result = parse_msgpack_internal();
9205 case input_format_t::ubjson:
9206 case input_format_t::bjdata:
9207 result = parse_ubjson_internal();
9210 case input_format_t::json:
9218 if (input_format == input_format_t::ubjson || input_format == input_format_t::bjdata)
9229 return sax->parse_error(chars_read, get_token_string(), parse_error::create(110, chars_read,
9230 exception_message(input_format,
concat(
"expected end of input; last byte: 0x", get_token_string()),
"value"),
nullptr));
9248 std::int32_t document_size{};
9249 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9261 return sax->end_object();
9273 auto out = std::back_inserter(result);
9281 if (current == 0x00)
9285 *out++ =
static_cast<typename string_t::value_type
>(current);
9300 template<
typename NumberType>
9305 auto last_token = get_token_string();
9306 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9307 exception_message(input_format_t::bson,
concat(
"string length must be at least 1, is ", std::to_string(len)),
"string"),
nullptr));
9322 template<
typename NumberType>
9327 auto last_token = get_token_string();
9328 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9329 exception_message(input_format_t::bson,
concat(
"byte array length cannot be negative, is ", std::to_string(len)),
"binary"),
nullptr));
9333 std::uint8_t subtype{};
9334 get_number<std::uint8_t>(input_format_t::bson, subtype);
9335 result.set_subtype(subtype);
9337 return get_binary(input_format_t::bson, len, result);
9353 switch (element_type)
9358 return get_number<double, true>(input_format_t::bson, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9365 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len,
value) && sax->string(
value);
9370 return parse_bson_internal();
9375 return parse_bson_array();
9382 return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len,
value) && sax->binary(
value);
9387 return sax->boolean(get() != 0);
9397 std::int32_t
value{};
9398 return get_number<std::int32_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9403 std::int64_t
value{};
9404 return get_number<std::int64_t, true>(input_format_t::bson,
value) && sax->number_integer(
value);
9409 std::array<char, 3> cr{{}};
9410 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(element_type)));
9411 const std::string cr_str{cr.data()};
9412 return sax->parse_error(element_type_parse_position, cr_str,
9413 parse_error::create(114, element_type_parse_position,
concat(
"Unsupported BSON record type 0x", cr_str),
nullptr));
9434 while (
auto element_type = get())
9441 const std::size_t element_type_parse_position = chars_read;
9447 if (!is_array && !sax->key(
key))
9452 if (
JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position)))
9470 std::int32_t document_size{};
9471 get_number<std::int32_t, true>(input_format_t::bson, document_size);
9483 return sax->end_array();
9501 switch (get_char ? get() : current)
9505 return unexpect_eof(input_format_t::cbor,
"value");
9536 std::uint8_t number{};
9537 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9542 std::uint16_t number{};
9543 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9548 std::uint32_t number{};
9549 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9554 std::uint64_t number{};
9555 return get_number(input_format_t::cbor, number) && sax->number_unsigned(number);
9583 return sax->number_integer(
static_cast<std::int8_t
>(0x20 - 1 - current));
9587 std::uint8_t number{};
9588 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9593 std::uint16_t number{};
9594 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9599 std::uint32_t number{};
9600 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1) - number);
9605 std::uint64_t number{};
9606 return get_number(input_format_t::cbor, number) && sax->number_integer(
static_cast<number_integer_t>(-1)
9642 return get_cbor_binary(b) && sax->binary(b);
9677 return get_cbor_string(s) && sax->string(s);
9705 return get_cbor_array(
9706 conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9711 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t>(len), tag_handler);
9716 std::uint16_t len{};
9717 return get_number(input_format_t::cbor, len) && get_cbor_array(
static_cast<std::size_t>(len), tag_handler);
9722 std::uint32_t len{};
9723 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9728 std::uint64_t len{};
9729 return get_number(input_format_t::cbor, len) && get_cbor_array(conditional_static_cast<std::size_t>(len), tag_handler);
9733 return get_cbor_array(
static_cast<std::size_t>(-1), tag_handler);
9760 return get_cbor_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x1Fu), tag_handler);
9765 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t>(len), tag_handler);
9770 std::uint16_t len{};
9771 return get_number(input_format_t::cbor, len) && get_cbor_object(
static_cast<std::size_t>(len), tag_handler);
9776 std::uint32_t len{};
9777 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9782 std::uint64_t len{};
9783 return get_number(input_format_t::cbor, len) && get_cbor_object(conditional_static_cast<std::size_t>(len), tag_handler);
9787 return get_cbor_object(
static_cast<std::size_t>(-1), tag_handler);
9809 switch (tag_handler)
9811 case cbor_tag_handler_t::error:
9813 auto last_token = get_token_string();
9814 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9815 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
9818 case cbor_tag_handler_t::ignore:
9825 std::uint8_t subtype_to_ignore{};
9826 get_number(input_format_t::cbor, subtype_to_ignore);
9831 std::uint16_t subtype_to_ignore{};
9832 get_number(input_format_t::cbor, subtype_to_ignore);
9837 std::uint32_t subtype_to_ignore{};
9838 get_number(input_format_t::cbor, subtype_to_ignore);
9843 std::uint64_t subtype_to_ignore{};
9844 get_number(input_format_t::cbor, subtype_to_ignore);
9850 return parse_cbor_internal(
true, tag_handler);
9853 case cbor_tag_handler_t::store:
9861 std::uint8_t subtype{};
9862 get_number(input_format_t::cbor, subtype);
9863 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9868 std::uint16_t subtype{};
9869 get_number(input_format_t::cbor, subtype);
9870 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9875 std::uint32_t subtype{};
9876 get_number(input_format_t::cbor, subtype);
9877 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9882 std::uint64_t subtype{};
9883 get_number(input_format_t::cbor, subtype);
9884 b.set_subtype(detail::conditional_static_cast<typename binary_t::subtype_type>(subtype));
9888 return parse_cbor_internal(
true, tag_handler);
9891 return get_cbor_binary(b) && sax->binary(b);
9901 return sax->boolean(
false);
9904 return sax->boolean(
true);
9911 const auto byte1_raw = get();
9916 const auto byte2_raw = get();
9922 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
9923 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
9933 const auto half =
static_cast<unsigned int>((byte1 << 8u) + byte2);
9934 const double val = [&half]
9936 const int exp = (half >> 10u) & 0x1Fu;
9937 const unsigned int mant = half & 0x3FFu;
9943 return std::ldexp(mant, -24);
9946 ? std::numeric_limits<double>::infinity()
9947 : std::numeric_limits<double>::quiet_NaN();
9949 return std::ldexp(mant + 1024, exp - 25);
9952 return sax->number_float((half & 0x8000u) != 0
9960 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9966 return get_number(input_format_t::cbor, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
9971 auto last_token = get_token_string();
9972 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
9973 exception_message(input_format_t::cbor,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10024 return get_string(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10029 std::uint8_t len{};
10030 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10035 std::uint16_t len{};
10036 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10041 std::uint32_t len{};
10042 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10047 std::uint64_t len{};
10048 return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result);
10053 while (get() != 0xFF)
10056 if (!get_cbor_string(chunk))
10060 result.append(chunk);
10067 auto last_token = get_token_string();
10068 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10069 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x", last_token),
"string"),
nullptr));
10120 return get_binary(input_format_t::cbor,
static_cast<unsigned int>(current) & 0x1Fu, result);
10125 std::uint8_t len{};
10126 return get_number(input_format_t::cbor, len) &&
10127 get_binary(input_format_t::cbor, len, result);
10132 std::uint16_t len{};
10133 return get_number(input_format_t::cbor, len) &&
10134 get_binary(input_format_t::cbor, len, result);
10139 std::uint32_t len{};
10140 return get_number(input_format_t::cbor, len) &&
10141 get_binary(input_format_t::cbor, len, result);
10146 std::uint64_t len{};
10147 return get_number(input_format_t::cbor, len) &&
10148 get_binary(input_format_t::cbor, len, result);
10153 while (get() != 0xFF)
10156 if (!get_cbor_binary(chunk))
10160 result.insert(result.end(), chunk.begin(), chunk.end());
10167 auto last_token = get_token_string();
10168 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10169 exception_message(input_format_t::cbor,
concat(
"expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x", last_token),
"binary"),
nullptr));
10200 while (get() != 0xFF)
10209 return sax->end_array();
10248 while (get() != 0xFF)
10264 return sax->end_object();
10280 return unexpect_eof(input_format_t::msgpack,
"value");
10430 return get_msgpack_object(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10449 return get_msgpack_array(conditional_static_cast<std::size_t>(
static_cast<unsigned int>(current) & 0x0Fu));
10489 return get_msgpack_string(s) && sax->string(s);
10493 return sax->null();
10496 return sax->boolean(
false);
10499 return sax->boolean(
true);
10514 return get_msgpack_binary(b) && sax->binary(b);
10520 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10526 return get_number(input_format_t::msgpack, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
10531 std::uint8_t number{};
10532 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10537 std::uint16_t number{};
10538 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10543 std::uint32_t number{};
10544 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10549 std::uint64_t number{};
10550 return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number);
10555 std::int8_t number{};
10556 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10561 std::int16_t number{};
10562 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10567 std::int32_t number{};
10568 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10573 std::int64_t number{};
10574 return get_number(input_format_t::msgpack, number) && sax->number_integer(number);
10579 std::uint16_t len{};
10580 return get_number(input_format_t::msgpack, len) && get_msgpack_array(
static_cast<std::size_t>(len));
10585 std::uint32_t len{};
10586 return get_number(input_format_t::msgpack, len) && get_msgpack_array(conditional_static_cast<std::size_t>(len));
10591 std::uint16_t len{};
10592 return get_number(input_format_t::msgpack, len) && get_msgpack_object(
static_cast<std::size_t>(len));
10597 std::uint32_t len{};
10598 return get_number(input_format_t::msgpack, len) && get_msgpack_object(conditional_static_cast<std::size_t>(len));
10634 return sax->number_integer(
static_cast<std::int8_t
>(current));
10638 auto last_token = get_token_string();
10639 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
10640 exception_message(input_format_t::msgpack,
concat(
"invalid byte: 0x", last_token),
"value"),
nullptr));
10698 return get_string(input_format_t::msgpack,
static_cast<unsigned int>(current) & 0x1Fu, result);
10703 std::uint8_t len{};
10704 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10709 std::uint16_t len{};
10710 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10715 std::uint32_t len{};
10716 return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result);
10721 auto last_token = get_token_string();
10722 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
10723 exception_message(input_format_t::msgpack,
concat(
"expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x", last_token),
"string"),
nullptr));
10741 auto assign_and_return_true = [&result](std::int8_t subtype)
10743 result.set_subtype(
static_cast<std::uint8_t
>(subtype));
10751 std::uint8_t len{};
10752 return get_number(input_format_t::msgpack, len) &&
10753 get_binary(input_format_t::msgpack, len, result);
10758 std::uint16_t len{};
10759 return get_number(input_format_t::msgpack, len) &&
10760 get_binary(input_format_t::msgpack, len, result);
10765 std::uint32_t len{};
10766 return get_number(input_format_t::msgpack, len) &&
10767 get_binary(input_format_t::msgpack, len, result);
10772 std::uint8_t len{};
10773 std::int8_t subtype{};
10774 return get_number(input_format_t::msgpack, len) &&
10775 get_number(input_format_t::msgpack, subtype) &&
10776 get_binary(input_format_t::msgpack, len, result) &&
10777 assign_and_return_true(subtype);
10782 std::uint16_t len{};
10783 std::int8_t subtype{};
10784 return get_number(input_format_t::msgpack, len) &&
10785 get_number(input_format_t::msgpack, subtype) &&
10786 get_binary(input_format_t::msgpack, len, result) &&
10787 assign_and_return_true(subtype);
10792 std::uint32_t len{};
10793 std::int8_t subtype{};
10794 return get_number(input_format_t::msgpack, len) &&
10795 get_number(input_format_t::msgpack, subtype) &&
10796 get_binary(input_format_t::msgpack, len, result) &&
10797 assign_and_return_true(subtype);
10802 std::int8_t subtype{};
10803 return get_number(input_format_t::msgpack, subtype) &&
10804 get_binary(input_format_t::msgpack, 1, result) &&
10805 assign_and_return_true(subtype);
10810 std::int8_t subtype{};
10811 return get_number(input_format_t::msgpack, subtype) &&
10812 get_binary(input_format_t::msgpack, 2, result) &&
10813 assign_and_return_true(subtype);
10818 std::int8_t subtype{};
10819 return get_number(input_format_t::msgpack, subtype) &&
10820 get_binary(input_format_t::msgpack, 4, result) &&
10821 assign_and_return_true(subtype);
10826 std::int8_t subtype{};
10827 return get_number(input_format_t::msgpack, subtype) &&
10828 get_binary(input_format_t::msgpack, 8, result) &&
10829 assign_and_return_true(subtype);
10834 std::int8_t subtype{};
10835 return get_number(input_format_t::msgpack, subtype) &&
10836 get_binary(input_format_t::msgpack, 16, result) &&
10837 assign_and_return_true(subtype);
10864 return sax->end_array();
10894 return sax->end_object();
10910 return get_ubjson_value(get_char ? get_ignore_noop() : current);
10943 std::uint8_t len{};
10944 return get_number(input_format, len) && get_string(input_format, len, result);
10950 return get_number(input_format, len) && get_string(input_format, len, result);
10955 std::int16_t len{};
10956 return get_number(input_format, len) && get_string(input_format, len, result);
10961 std::int32_t len{};
10962 return get_number(input_format, len) && get_string(input_format, len, result);
10967 std::int64_t len{};
10968 return get_number(input_format, len) && get_string(input_format, len, result);
10973 if (input_format != input_format_t::bjdata)
10977 std::uint16_t len{};
10978 return get_number(input_format, len) && get_string(input_format, len, result);
10983 if (input_format != input_format_t::bjdata)
10987 std::uint32_t len{};
10988 return get_number(input_format, len) && get_string(input_format, len, result);
10993 if (input_format != input_format_t::bjdata)
10997 std::uint64_t len{};
10998 return get_number(input_format, len) && get_string(input_format, len, result);
11004 auto last_token = get_token_string();
11005 std::string message;
11007 if (input_format != input_format_t::bjdata)
11009 message =
"expected length type specification (U, i, I, l, L); last byte: 0x" + last_token;
11013 message =
"expected length type specification (U, i, u, I, m, l, M, L); last byte: 0x" + last_token;
11015 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"string"),
nullptr));
11024 std::pair<std::size_t, char_int_type> size_and_type;
11026 bool no_ndarray =
true;
11033 if (size_and_type.first != npos)
11035 if (size_and_type.second != 0)
11037 if (size_and_type.second !=
'N')
11039 for (
std::size_t i = 0; i < size_and_type.first; ++i)
11045 dim.push_back(dimlen);
11051 for (
std::size_t i = 0; i < size_and_type.first; ++i)
11057 dim.push_back(dimlen);
11063 while (current !=
']')
11069 dim.push_back(dimlen);
11091 prefix = get_ignore_noop();
11098 std::uint8_t number{};
11109 std::int8_t number{};
11116 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11117 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11125 std::int16_t number{};
11132 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11133 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11141 std::int32_t number{};
11148 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11149 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11157 std::int64_t number{};
11164 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read,
11165 exception_message(input_format,
"count in an optimized container must be positive",
"size"),
nullptr));
11167 if (!value_in_range_of<std::size_t>(number))
11169 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11170 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11178 if (input_format != input_format_t::bjdata)
11182 std::uint16_t number{};
11193 if (input_format != input_format_t::bjdata)
11197 std::uint32_t number{};
11202 result = conditional_static_cast<std::size_t>(number);
11208 if (input_format != input_format_t::bjdata)
11212 std::uint64_t number{};
11217 if (!value_in_range_of<std::size_t>(number))
11219 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408,
11220 exception_message(input_format,
"integer value overflow",
"size"),
nullptr));
11222 result = detail::conditional_static_cast<std::size_t>(number);
11228 if (input_format != input_format_t::bjdata)
11234 return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format,
"ndarray dimensional vector is not allowed",
"size"),
nullptr));
11236 std::vector<size_t> dim;
11241 if (dim.size() == 1 || (dim.size() == 2 && dim.at(0) == 1))
11243 result = dim.at(dim.size() - 1);
11266 if (result == 0 || result == npos)
11268 return sax->parse_error(chars_read, get_token_string(), out_of_range::create(408, exception_message(input_format,
"excessive ndarray size caused overflow",
"size"),
nullptr));
11276 return sax->end_array();
11285 auto last_token = get_token_string();
11286 std::string message;
11288 if (input_format != input_format_t::bjdata)
11290 message =
"expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token;
11294 message =
"expected length type specification (U, i, u, I, m, l, M, L) after '#'; last byte: 0x" + last_token;
11296 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format, message,
"size"),
nullptr));
11312 result.first = npos;
11314 bool is_ndarray =
false;
11318 if (current ==
'$')
11320 result.second = get();
11321 if (input_format == input_format_t::bjdata
11322 &&
JSON_HEDLEY_UNLIKELY(std::binary_search(bjd_optimized_type_markers.begin(), bjd_optimized_type_markers.end(), result.second)))
11324 auto last_token = get_token_string();
11325 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11326 exception_message(input_format,
concat(
"marker 0x", last_token,
" is not a permitted optimized array type"),
"type"),
nullptr));
11341 auto last_token = get_token_string();
11342 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11343 exception_message(input_format,
concat(
"expected '#' after type information; last byte: 0x", last_token),
"size"),
nullptr));
11346 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11347 if (input_format == input_format_t::bjdata && is_ndarray)
11349 if (inside_ndarray)
11351 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
11352 exception_message(input_format,
"ndarray can not be recursive",
"size"),
nullptr));
11354 result.second |= (1 << 8);
11359 if (current ==
'#')
11361 const bool is_error = get_ubjson_size_value(result.first, is_ndarray);
11362 if (input_format == input_format_t::bjdata && is_ndarray)
11364 return sax->parse_error(chars_read, get_token_string(), parse_error::create(112, chars_read,
11365 exception_message(input_format,
"ndarray requires both type and size",
"size"),
nullptr));
11382 return unexpect_eof(input_format,
"value");
11385 return sax->boolean(
true);
11387 return sax->boolean(
false);
11390 return sax->null();
11394 std::uint8_t number{};
11395 return get_number(input_format, number) && sax->number_unsigned(number);
11400 std::int8_t number{};
11401 return get_number(input_format, number) && sax->number_integer(number);
11406 std::int16_t number{};
11407 return get_number(input_format, number) && sax->number_integer(number);
11412 std::int32_t number{};
11413 return get_number(input_format, number) && sax->number_integer(number);
11418 std::int64_t number{};
11419 return get_number(input_format, number) && sax->number_integer(number);
11424 if (input_format != input_format_t::bjdata)
11428 std::uint16_t number{};
11429 return get_number(input_format, number) && sax->number_unsigned(number);
11434 if (input_format != input_format_t::bjdata)
11438 std::uint32_t number{};
11439 return get_number(input_format, number) && sax->number_unsigned(number);
11444 if (input_format != input_format_t::bjdata)
11448 std::uint64_t number{};
11449 return get_number(input_format, number) && sax->number_unsigned(number);
11454 if (input_format != input_format_t::bjdata)
11458 const auto byte1_raw = get();
11463 const auto byte2_raw = get();
11469 const auto byte1 =
static_cast<unsigned char>(byte1_raw);
11470 const auto byte2 =
static_cast<unsigned char>(byte2_raw);
11480 const auto half =
static_cast<unsigned int>((byte2 << 8u) + byte1);
11481 const double val = [&half]
11483 const int exp = (half >> 10u) & 0x1Fu;
11484 const unsigned int mant = half & 0x3FFu;
11490 return std::ldexp(mant, -24);
11493 ? std::numeric_limits<double>::infinity()
11494 : std::numeric_limits<double>::quiet_NaN();
11496 return std::ldexp(mant + 1024, exp - 25);
11499 return sax->number_float((half & 0x8000u) != 0
11507 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11513 return get_number(input_format, number) && sax->number_float(
static_cast<number_float_t>(number),
"");
11518 return get_ubjson_high_precision_number();
11530 auto last_token = get_token_string();
11531 return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read,
11532 exception_message(input_format,
concat(
"byte after 'C' must be in range 0x00..0x7F; last byte: 0x", last_token),
"char"),
nullptr));
11534 string_t s(1,
static_cast<typename string_t::value_type
>(current));
11535 return sax->string(s);
11541 return get_ubjson_string(s) && sax->string(s);
11545 return get_ubjson_array();
11548 return get_ubjson_object();
11553 auto last_token = get_token_string();
11554 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format,
"invalid byte: 0x" + last_token,
"value"),
nullptr));
11562 std::pair<std::size_t, char_int_type> size_and_type;
11571 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11573 size_and_type.second &= ~(
static_cast<char_int_type>(1) << 8);
11574 auto it = std::lower_bound(bjd_types_map.begin(), bjd_types_map.end(), size_and_type.second, [](
const bjd_type & p,
char_int_type t)
11576 return p.first < t;
11581 auto last_token = get_token_string();
11582 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11583 exception_message(input_format,
"invalid byte: 0x" + last_token,
"type"),
nullptr));
11592 if (size_and_type.second ==
'C')
11594 size_and_type.second =
'U';
11597 key =
"_ArrayData_";
11603 for (
std::size_t i = 0; i < size_and_type.first; ++i)
11611 return (sax->end_array() && sax->end_object());
11614 if (size_and_type.first != npos)
11621 if (size_and_type.second != 0)
11623 if (size_and_type.second !=
'N')
11625 for (
std::size_t i = 0; i < size_and_type.first; ++i)
11636 for (
std::size_t i = 0; i < size_and_type.first; ++i)
11652 while (current !=
']')
11662 return sax->end_array();
11670 std::pair<std::size_t, char_int_type> size_and_type;
11677 if (input_format == input_format_t::bjdata && size_and_type.first != npos && (size_and_type.second & (1 << 8)) != 0)
11679 auto last_token = get_token_string();
11680 return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read,
11681 exception_message(input_format,
"BJData object does not support ND-array size in optimized format",
"object"),
nullptr));
11685 if (size_and_type.first != npos)
11692 if (size_and_type.second != 0)
11694 for (
std::size_t i = 0; i < size_and_type.first; ++i)
11709 for (
std::size_t i = 0; i < size_and_type.first; ++i)
11730 while (current !=
'}')
11745 return sax->end_object();
11755 bool no_ndarray =
true;
11756 auto res = get_ubjson_size_value(size, no_ndarray);
11763 std::vector<char> number_vector;
11771 number_vector.push_back(
static_cast<char>(current));
11777 const auto result_number = number_lexer.scan();
11778 const auto number_string = number_lexer.get_token_string();
11779 const auto result_remainder = number_lexer.scan();
11785 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
11786 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11789 switch (result_number)
11791 case token_type::value_integer:
11792 return sax->number_integer(number_lexer.get_number_integer());
11793 case token_type::value_unsigned:
11794 return sax->number_unsigned(number_lexer.get_number_unsigned());
11795 case token_type::value_float:
11796 return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
11797 case token_type::uninitialized:
11798 case token_type::literal_true:
11799 case token_type::literal_false:
11800 case token_type::literal_null:
11801 case token_type::value_string:
11802 case token_type::begin_array:
11803 case token_type::begin_object:
11804 case token_type::end_array:
11805 case token_type::end_object:
11806 case token_type::name_separator:
11807 case token_type::value_separator:
11808 case token_type::parse_error:
11809 case token_type::end_of_input:
11810 case token_type::literal_or_value:
11812 return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read,
11813 exception_message(input_format,
concat(
"invalid number text: ", number_lexer.get_token_string()),
"high-precision number"),
nullptr));
11833 return current = ia.get_character();
11845 while (current ==
'N');
11865 template<
typename NumberType,
bool InputIsLittleEndian = false>
11869 std::array<std::uint8_t,
sizeof(NumberType)> vec{};
11870 for (
std::size_t i = 0; i <
sizeof(NumberType); ++i)
11879 if (is_little_endian != (InputIsLittleEndian || format == input_format_t::bjdata))
11881 vec[
sizeof(NumberType) - i - 1] =
static_cast<std::uint8_t
>(current);
11885 vec[i] =
static_cast<std::uint8_t
>(current);
11890 std::memcpy(&result, vec.data(),
sizeof(NumberType));
11908 template<
typename NumberType>
11910 const NumberType len,
11913 bool success =
true;
11914 for (NumberType i = 0; i < len; i++)
11922 result.push_back(
static_cast<typename string_t::value_type
>(current));
11941 template<
typename NumberType>
11943 const NumberType len,
11946 bool success =
true;
11947 for (NumberType i = 0; i < len; i++)
11955 result.push_back(
static_cast<std::uint8_t
>(current));
11970 return sax->parse_error(chars_read,
"<end of file>",
11971 parse_error::create(110, chars_read, exception_message(format,
"unexpected end of input", context),
nullptr));
11981 std::array<char, 3> cr{{}};
11982 static_cast<void>((std::snprintf)(cr.data(), cr.size(),
"%.2hhX",
static_cast<unsigned char>(current)));
11983 return std::string{cr.data()};
11993 const std::string&
detail,
11994 const std::string& context)
const
11996 std::string error_msg =
"syntax error while parsing ";
12000 case input_format_t::cbor:
12001 error_msg +=
"CBOR";
12004 case input_format_t::msgpack:
12005 error_msg +=
"MessagePack";
12008 case input_format_t::ubjson:
12009 error_msg +=
"UBJSON";
12012 case input_format_t::bson:
12013 error_msg +=
"BSON";
12016 case input_format_t::bjdata:
12017 error_msg +=
"BJData";
12020 case input_format_t::json:
12032 InputAdapterType ia;
12047 json_sax_t* sax =
nullptr;
12050#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_ \
12051 make_array<char_int_type>('F', 'H', 'N', 'S', 'T', 'Z', '[', '{')
12053#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_ \
12054 make_array<bjd_type>( \
12055 bjd_type{'C', "char"}, \
12056 bjd_type{'D', "double"}, \
12057 bjd_type{'I', "int16"}, \
12058 bjd_type{'L', "int64"}, \
12059 bjd_type{'M', "uint64"}, \
12060 bjd_type{'U', "uint8"}, \
12061 bjd_type{'d', "single"}, \
12062 bjd_type{'i', "int8"}, \
12063 bjd_type{'l', "int32"}, \
12064 bjd_type{'m', "uint32"}, \
12065 bjd_type{'u', "uint16"})
12078#undef JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
12079#undef JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
12082#ifndef JSON_HAS_CPP_17
12083 template<
typename BasicJsonType,
typename InputAdapterType,
typename SAX>
12107#include <functional>
12152template<
typename BasicJsonType>
12153using parser_callback_t =
12154 std::function<bool(
int , parse_event_t , BasicJsonType& )>;
12161template<
typename BasicJsonType,
typename InputAdapterType>
12168 using lexer_t = lexer<BasicJsonType, InputAdapterType>;
12174 const parser_callback_t<BasicJsonType> cb =
nullptr,
12175 const bool allow_exceptions_ =
true,
12176 const bool skip_comments =
false)
12178 , m_lexer(
std::move(adapter), skip_comments)
12179 , allow_exceptions(allow_exceptions_)
12195 void parse(
const bool strict, BasicJsonType& result)
12199 json_sax_dom_callback_parser<BasicJsonType> sdp(result, callback, allow_exceptions);
12200 sax_parse_internal(&sdp);
12203 if (
strict && (get_token() != token_type::end_of_input))
12205 sdp.parse_error(m_lexer.get_position(),
12206 m_lexer.get_token_string(),
12207 parse_error::create(101, m_lexer.get_position(),
12208 exception_message(token_type::end_of_input,
"value"),
nullptr));
12212 if (sdp.is_errored())
12214 result = value_t::discarded;
12220 if (result.is_discarded())
12227 json_sax_dom_parser<BasicJsonType> sdp(result, allow_exceptions);
12228 sax_parse_internal(&sdp);
12231 if (
strict && (get_token() != token_type::end_of_input))
12233 sdp.parse_error(m_lexer.get_position(),
12234 m_lexer.get_token_string(),
12235 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12239 if (sdp.is_errored())
12241 result = value_t::discarded;
12246 result.assert_invariant();
12257 json_sax_acceptor<BasicJsonType> sax_acceptor;
12258 return sax_parse(&sax_acceptor,
strict);
12261 template<
typename SAX>
12263 bool sax_parse(SAX* sax, const
bool strict = true)
12266 const bool result = sax_parse_internal(sax);
12269 if (result &&
strict && (get_token() != token_type::end_of_input))
12271 return sax->parse_error(m_lexer.get_position(),
12272 m_lexer.get_token_string(),
12273 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input,
"value"),
nullptr));
12280 template<
typename SAX>
12282 bool sax_parse_internal(SAX* sax)
12286 std::vector<bool> states;
12288 bool skip_to_state_evaluation =
false;
12292 if (!skip_to_state_evaluation)
12295 switch (last_token)
12297 case token_type::begin_object:
12305 if (get_token() == token_type::end_object)
12317 return sax->parse_error(m_lexer.get_position(),
12318 m_lexer.get_token_string(),
12319 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12329 return sax->parse_error(m_lexer.get_position(),
12330 m_lexer.get_token_string(),
12331 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12335 states.push_back(
false);
12342 case token_type::begin_array:
12350 if (get_token() == token_type::end_array)
12360 states.push_back(
true);
12366 case token_type::value_float:
12368 const auto res = m_lexer.get_number_float();
12372 return sax->parse_error(m_lexer.get_position(),
12373 m_lexer.get_token_string(),
12374 out_of_range::create(406,
concat(
"number overflow parsing '", m_lexer.get_token_string(),
'\''),
nullptr));
12385 case token_type::literal_false:
12394 case token_type::literal_null:
12403 case token_type::literal_true:
12412 case token_type::value_integer:
12421 case token_type::value_string:
12430 case token_type::value_unsigned:
12439 case token_type::parse_error:
12442 return sax->parse_error(m_lexer.get_position(),
12443 m_lexer.get_token_string(),
12444 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized,
"value"),
nullptr));
12447 case token_type::uninitialized:
12448 case token_type::end_array:
12449 case token_type::end_object:
12450 case token_type::name_separator:
12451 case token_type::value_separator:
12452 case token_type::end_of_input:
12453 case token_type::literal_or_value:
12456 return sax->parse_error(m_lexer.get_position(),
12457 m_lexer.get_token_string(),
12458 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value,
"value"),
nullptr));
12464 skip_to_state_evaluation =
false;
12468 if (states.empty())
12477 if (get_token() == token_type::value_separator)
12498 skip_to_state_evaluation =
true;
12502 return sax->parse_error(m_lexer.get_position(),
12503 m_lexer.get_token_string(),
12504 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array,
"array"),
nullptr));
12510 if (get_token() == token_type::value_separator)
12515 return sax->parse_error(m_lexer.get_position(),
12516 m_lexer.get_token_string(),
12517 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string,
"object key"),
nullptr));
12528 return sax->parse_error(m_lexer.get_position(),
12529 m_lexer.get_token_string(),
12530 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator,
"object separator"),
nullptr));
12552 skip_to_state_evaluation =
true;
12556 return sax->parse_error(m_lexer.get_position(),
12557 m_lexer.get_token_string(),
12558 parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object,
"object"),
nullptr));
12565 return last_token = m_lexer.scan();
12570 std::string error_msg =
"syntax error ";
12572 if (!context.empty())
12574 error_msg +=
concat(
"while parsing ", context,
' ');
12579 if (last_token == token_type::parse_error)
12581 error_msg +=
concat(m_lexer.get_error_message(),
"; last read: '",
12582 m_lexer.get_token_string(),
'\'');
12586 error_msg +=
concat(
"unexpected ", lexer_t::token_type_name(last_token));
12589 if (expected != token_type::uninitialized)
12591 error_msg +=
concat(
"; expected ", lexer_t::token_type_name(expected));
12599 const parser_callback_t<BasicJsonType> callback =
nullptr;
12601 token_type last_token = token_type::uninitialized;
12605 const bool allow_exceptions =
true;
12654class primitive_iterator_t
12674 m_it = begin_value;
12686 return m_it == begin_value;
12692 return m_it == end_value;
12697 return lhs.m_it == rhs.m_it;
12702 return lhs.m_it < rhs.m_it;
12707 auto result = *
this;
12714 return lhs.m_it - rhs.m_it;
12725 auto result = *
this;
12738 auto result = *
this;
12770template<
typename BasicJsonType>
struct internal_iterator
12773 typename BasicJsonType::object_t::iterator object_iterator {};
12775 typename BasicJsonType::array_t::iterator array_iterator {};
12777 primitive_iterator_t primitive_iterator {};
12795#include <type_traits>
12817template<
typename IteratorType>
class iteration_proxy;
12818template<
typename IteratorType>
class iteration_proxy_value;
12836template<
typename BasicJsonType>
12840 using other_iter_impl = iter_impl<typename std::conditional<std::is_const<BasicJsonType>::value,
typename std::remove_const<BasicJsonType>::type,
const BasicJsonType>::type>;
12843 friend BasicJsonType;
12844 friend iteration_proxy<iter_impl>;
12845 friend iteration_proxy_value<iter_impl>;
12850 static_assert(is_basic_json<typename std::remove_const<BasicJsonType>::type>::value,
12851 "iter_impl only accepts (const) basic_json");
12853 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
12854 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>::value,
12855 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
12870 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
12871 typename BasicJsonType::const_pointer,
12872 typename BasicJsonType::pointer>::type;
12875 typename std::conditional<std::is_const<BasicJsonType>::value,
12876 typename BasicJsonType::const_reference,
12877 typename BasicJsonType::reference>::type;
12894 switch (m_object->m_type)
12896 case value_t::object:
12898 m_it.object_iterator =
typename object_t::iterator();
12902 case value_t::array:
12904 m_it.array_iterator =
typename array_t::iterator();
12908 case value_t::null:
12909 case value_t::string:
12910 case value_t::boolean:
12911 case value_t::number_integer:
12912 case value_t::number_unsigned:
12913 case value_t::number_float:
12914 case value_t::binary:
12915 case value_t::discarded:
12941 : m_object(other.m_object), m_it(other.m_it)
12952 if (&other !=
this)
12954 m_object = other.m_object;
12966 : m_object(other.m_object), m_it(other.m_it)
12977 m_object = other.m_object;
12987 void set_begin() noexcept
12991 switch (m_object->m_type)
12993 case value_t::object:
12995 m_it.object_iterator = m_object->m_value.object->begin();
12999 case value_t::array:
13001 m_it.array_iterator = m_object->m_value.array->begin();
13005 case value_t::null:
13008 m_it.primitive_iterator.set_end();
13012 case value_t::string:
13013 case value_t::boolean:
13014 case value_t::number_integer:
13015 case value_t::number_unsigned:
13016 case value_t::number_float:
13017 case value_t::binary:
13018 case value_t::discarded:
13021 m_it.primitive_iterator.set_begin();
13035 switch (m_object->m_type)
13037 case value_t::object:
13039 m_it.object_iterator = m_object->m_value.object->end();
13043 case value_t::array:
13045 m_it.array_iterator = m_object->m_value.array->end();
13049 case value_t::null:
13050 case value_t::string:
13051 case value_t::boolean:
13052 case value_t::number_integer:
13053 case value_t::number_unsigned:
13054 case value_t::number_float:
13055 case value_t::binary:
13056 case value_t::discarded:
13059 m_it.primitive_iterator.set_end();
13074 switch (m_object->m_type)
13076 case value_t::object:
13078 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
13079 return m_it.object_iterator->second;
13082 case value_t::array:
13084 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
13085 return *m_it.array_iterator;
13088 case value_t::null:
13089 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13091 case value_t::string:
13092 case value_t::boolean:
13093 case value_t::number_integer:
13094 case value_t::number_unsigned:
13095 case value_t::number_float:
13096 case value_t::binary:
13097 case value_t::discarded:
13105 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13118 switch (m_object->m_type)
13120 case value_t::object:
13122 JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end());
13123 return &(m_it.object_iterator->second);
13126 case value_t::array:
13128 JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end());
13129 return &*m_it.array_iterator;
13132 case value_t::null:
13133 case value_t::string:
13134 case value_t::boolean:
13135 case value_t::number_integer:
13136 case value_t::number_unsigned:
13137 case value_t::number_float:
13138 case value_t::binary:
13139 case value_t::discarded:
13147 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13158 auto result = *
this;
13171 switch (m_object->m_type)
13173 case value_t::object:
13175 std::advance(m_it.object_iterator, 1);
13179 case value_t::array:
13181 std::advance(m_it.array_iterator, 1);
13185 case value_t::null:
13186 case value_t::string:
13187 case value_t::boolean:
13188 case value_t::number_integer:
13189 case value_t::number_unsigned:
13190 case value_t::number_float:
13191 case value_t::binary:
13192 case value_t::discarded:
13195 ++m_it.primitive_iterator;
13209 auto result = *
this;
13222 switch (m_object->m_type)
13224 case value_t::object:
13226 std::advance(m_it.object_iterator, -1);
13230 case value_t::array:
13232 std::advance(m_it.array_iterator, -1);
13236 case value_t::null:
13237 case value_t::string:
13238 case value_t::boolean:
13239 case value_t::number_integer:
13240 case value_t::number_unsigned:
13241 case value_t::number_float:
13242 case value_t::binary:
13243 case value_t::discarded:
13246 --m_it.primitive_iterator;
13258 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13264 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
13269 switch (m_object->m_type)
13271 case value_t::object:
13272 return (m_it.object_iterator == other.m_it.object_iterator);
13274 case value_t::array:
13275 return (m_it.array_iterator == other.m_it.array_iterator);
13277 case value_t::null:
13278 case value_t::string:
13279 case value_t::boolean:
13280 case value_t::number_integer:
13281 case value_t::number_unsigned:
13282 case value_t::number_float:
13283 case value_t::binary:
13284 case value_t::discarded:
13286 return (m_it.primitive_iterator == other.m_it.primitive_iterator);
13294 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
13309 JSON_THROW(invalid_iterator::create(212,
"cannot compare iterators of different containers", m_object));
13314 switch (m_object->m_type)
13316 case value_t::object:
13317 JSON_THROW(invalid_iterator::create(213,
"cannot compare order of object iterators", m_object));
13319 case value_t::array:
13320 return (m_it.array_iterator < other.m_it.array_iterator);
13322 case value_t::null:
13323 case value_t::string:
13324 case value_t::boolean:
13325 case value_t::number_integer:
13326 case value_t::number_unsigned:
13327 case value_t::number_float:
13328 case value_t::binary:
13329 case value_t::discarded:
13331 return (m_it.primitive_iterator < other.m_it.primitive_iterator);
13341 return !other.operator < (*this);
13350 return !operator<=(other);
13370 switch (m_object->m_type)
13372 case value_t::object:
13373 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
13375 case value_t::array:
13377 std::advance(m_it.array_iterator, i);
13381 case value_t::null:
13382 case value_t::string:
13383 case value_t::boolean:
13384 case value_t::number_integer:
13385 case value_t::number_unsigned:
13386 case value_t::number_float:
13387 case value_t::binary:
13388 case value_t::discarded:
13391 m_it.primitive_iterator += i;
13405 return operator+=(-i);
13414 auto result = *
this;
13436 auto result = *
this;
13449 switch (m_object->m_type)
13451 case value_t::object:
13452 JSON_THROW(invalid_iterator::create(209,
"cannot use offsets with object iterators", m_object));
13454 case value_t::array:
13455 return m_it.array_iterator - other.m_it.array_iterator;
13457 case value_t::null:
13458 case value_t::string:
13459 case value_t::boolean:
13460 case value_t::number_integer:
13461 case value_t::number_unsigned:
13462 case value_t::number_float:
13463 case value_t::binary:
13464 case value_t::discarded:
13466 return m_it.primitive_iterator - other.m_it.primitive_iterator;
13478 switch (m_object->m_type)
13480 case value_t::object:
13481 JSON_THROW(invalid_iterator::create(208,
"cannot use operator[] for object iterators", m_object));
13483 case value_t::array:
13484 return *std::next(m_it.array_iterator, n);
13486 case value_t::null:
13487 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13489 case value_t::string:
13490 case value_t::boolean:
13491 case value_t::number_integer:
13492 case value_t::number_unsigned:
13493 case value_t::number_float:
13494 case value_t::binary:
13495 case value_t::discarded:
13503 JSON_THROW(invalid_iterator::create(214,
"cannot get value", m_object));
13512 const typename object_t::key_type&
key()
const
13518 return m_it.object_iterator->first;
13521 JSON_THROW(invalid_iterator::create(207,
"cannot use key() for non-object iterators", m_object));
13530 return operator*();
13535 pointer m_object =
nullptr;
13537 internal_iterator<typename std::remove_const<BasicJsonType>::type> m_it {};
13589template<
typename Base>
13590class json_reverse_iterator :
public std::reverse_iterator<Base>
13657 return *(this->operator+(n));
13661 auto key() const -> decltype(
std::declval<Base>().key())
13663 auto it = --this->base();
13670 auto it = --this->base();
13671 return it.operator * ();
13683#include <type_traits>
13702struct json_default_base {};
13706 std::is_same<T, void>::value,
13725#include <algorithm>
13753template<
typename RefStringType>
13763 template<
typename T>
13782 : reference_tokens(split(s))
13789 return std::accumulate(reference_tokens.begin(), reference_tokens.end(),
13793 return detail::concat(a,
'/', detail::escape(b));
13819 reference_tokens.insert(reference_tokens.end(),
13829 push_back(std::move(token));
13837 return *
this /= std::to_string(array_idx);
13885 reference_tokens.pop_back();
13897 return reference_tokens.back();
13904 reference_tokens.push_back(token);
13911 reference_tokens.push_back(std::move(token));
13918 return reference_tokens.empty();
13932 template<
typename BasicJsonType>
13935 using size_type =
typename BasicJsonType::size_type;
13949 const char* p = s.c_str();
13950 char* p_end =
nullptr;
13952 const unsigned long long res = std::strtoull(p, &p_end, 10);
13962 if (res >=
static_cast<unsigned long long>((std::numeric_limits<size_type>::max)()))
13967 return static_cast<size_type
>(res);
13992 template<
typename BasicJsonType>
13999 for (
const auto& reference_token : reference_tokens)
14001 switch (result->type())
14005 if (reference_token ==
"0")
14008 result = &result->operator[](0);
14013 result = &result->operator[](reference_token);
14021 result = &result->operator[](reference_token);
14028 result = &result->operator[](array_index<BasicJsonType>(reference_token));
14072 template<
typename BasicJsonType>
14075 for (
const auto& reference_token : reference_tokens)
14078 if (ptr->is_null())
14082 std::all_of(reference_token.begin(), reference_token.end(),
14083 [](
const unsigned char x)
14085 return std::isdigit(x);
14089 *ptr = (nums || reference_token ==
"-")
14094 switch (ptr->type())
14099 ptr = &ptr->operator[](reference_token);
14105 if (reference_token ==
"-")
14108 ptr = &ptr->operator[](ptr->m_value.array->size());
14113 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14140 template<
typename BasicJsonType>
14143 for (
const auto& reference_token : reference_tokens)
14145 switch (ptr->type())
14150 ptr = &ptr->at(reference_token);
14160 "array index '-' (", std::to_string(ptr->m_value.array->size()),
14161 ") is out of range"), ptr));
14165 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14198 template<
typename BasicJsonType>
14201 for (
const auto& reference_token : reference_tokens)
14203 switch (ptr->type())
14208 ptr = &ptr->operator[](reference_token);
14221 ptr = &ptr->operator[](array_index<BasicJsonType>(reference_token));
14247 template<
typename BasicJsonType>
14250 for (
const auto& reference_token : reference_tokens)
14252 switch (ptr->type())
14257 ptr = &ptr->at(reference_token);
14267 "array index '-' (", std::to_string(ptr->m_value.array->size()),
14268 ") is out of range"), ptr));
14272 ptr = &ptr->at(array_index<BasicJsonType>(reference_token));
14296 template<
typename BasicJsonType>
14299 for (
const auto& reference_token : reference_tokens)
14301 switch (ptr->type())
14305 if (!ptr->contains(reference_token))
14311 ptr = &ptr->operator[](reference_token);
14322 if (
JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !(
"0" <= reference_token && reference_token <=
"9")))
14334 for (
std::size_t i = 1; i < reference_token.size(); i++)
14344 const auto idx = array_index<BasicJsonType>(reference_token);
14345 if (idx >= ptr->size())
14351 ptr = &ptr->operator[](idx);
14387 std::vector<string_t> result;
14390 if (reference_string.empty())
14406 std::size_t slash = reference_string.find_first_of(
'/', 1),
14413 start = (slash == string_t::npos) ? 0 : slash + 1,
14415 slash = reference_string.find_first_of(
'/', start))
14419 auto reference_token = reference_string.substr(start, slash - start);
14422 for (
std::size_t pos = reference_token.find_first_of(
'~');
14423 pos != string_t::npos;
14424 pos = reference_token.find_first_of(
'~', pos + 1))
14430 (reference_token[pos + 1] !=
'0' &&
14431 reference_token[pos + 1] !=
'1')))
14439 result.push_back(reference_token);
14453 template<
typename BasicJsonType>
14455 const BasicJsonType& value,
14456 BasicJsonType& result)
14458 switch (value.type())
14462 if (value.m_value.array->empty())
14465 result[reference_string] =
nullptr;
14470 for (
std::size_t i = 0; i < value.m_value.array->size(); ++i)
14472 flatten(
detail::concat(reference_string,
'/', std::to_string(i)),
14473 value.m_value.array->operator[](i), result);
14481 if (value.m_value.object->empty())
14484 result[reference_string] =
nullptr;
14489 for (
const auto& element : *value.m_value.object)
14508 result[reference_string] = value;
14524 template<
typename BasicJsonType>
14525 static BasicJsonType
14533 BasicJsonType result;
14536 for (
const auto& element : *value.m_value.object)
14556 json_pointer<string_t> result;
14557 result.reference_tokens = reference_tokens;
14563 json_pointer<string_t> result;
14564 result.reference_tokens = std::move(reference_tokens);
14569#if JSON_HAS_THREE_WAY_COMPARISON
14572 template<
typename RefStringTypeRhs>
14573 bool operator==(
const json_pointer<RefStringTypeRhs>& rhs)
const noexcept
14575 return reference_tokens == rhs.reference_tokens;
14587 template<
typename RefStringTypeRhs>
14588 std::strong_ordering operator<=>(
const json_pointer<RefStringTypeRhs>& rhs)
const noexcept
14590 return reference_tokens <=> rhs.reference_tokens;
14595 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14597 friend bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
14598 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
14602 template<
typename RefStringTypeLhs,
typename StringType>
14604 friend bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
14605 const StringType& rhs);
14609 template<
typename RefStringTypeRhs,
typename StringType>
14611 friend bool operator==(
const StringType& lhs,
14612 const json_pointer<RefStringTypeRhs>& rhs);
14616 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14618 friend bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
14619 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
14623 template<
typename RefStringTypeLhs,
typename StringType>
14625 friend bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
14626 const StringType& rhs);
14630 template<
typename RefStringTypeRhs,
typename StringType>
14632 friend bool operator!=(
const StringType& lhs,
14633 const json_pointer<RefStringTypeRhs>& rhs);
14636 template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14638 friend bool operator<(
const json_pointer<RefStringTypeLhs>& lhs,
14639 const json_pointer<RefStringTypeRhs>& rhs)
noexcept;
14644 std::vector<string_t> reference_tokens;
14647#if !JSON_HAS_THREE_WAY_COMPARISON
14649template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14651 const json_pointer<RefStringTypeRhs>& rhs)
noexcept
14653 return lhs.reference_tokens == rhs.reference_tokens;
14656template<
typename RefStringTypeLhs,
14660 const StringType& rhs)
14662 return lhs == json_pointer<RefStringTypeLhs>(rhs);
14665template<
typename RefStringTypeRhs,
14668inline
bool operator==(const StringType& lhs,
14671 return json_pointer<RefStringTypeRhs>(lhs) == rhs;
14674template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14676 const json_pointer<RefStringTypeRhs>& rhs)
noexcept
14678 return !(lhs == rhs);
14681template<
typename RefStringTypeLhs,
14685 const StringType& rhs)
14687 return !(lhs == rhs);
14690template<
typename RefStringTypeRhs,
14693inline
bool operator!=(const StringType& lhs,
14696 return !(lhs == rhs);
14699template<
typename RefStringTypeLhs,
typename RefStringTypeRhs>
14701 const json_pointer<RefStringTypeRhs>& rhs)
noexcept
14703 return lhs.reference_tokens < rhs.reference_tokens;
14720#include <initializer_list>
14732template<
typename BasicJsonType>
14743 : value_ref(&
value)
14747 : owned_value(init)
14752 enable_if_t<std::is_constructible<value_type, Args...>::value,
int> = 0 >
14754 : owned_value(
std::forward<Args>(args)...)
14766 if (value_ref ==
nullptr)
14768 return std::move(owned_value);
14775 return value_ref ? *value_ref : owned_value;
14784 mutable value_type owned_value =
nullptr;
14785 value_type
const* value_ref =
nullptr;
14812#include <algorithm>
14838#include <algorithm>
14858template<
typename CharType>
struct output_adapter_protocol
14872template<typename CharType>
14876template<typename CharType, typename AllocatorType =
std::allocator<CharType>>
14890 void write_characters(const CharType* s,
std::
size_t length)
override
14892 v.insert(v.end(), s, s + length);
14896 std::vector<CharType, AllocatorType>& v;
14901template<
typename CharType>
14902class output_stream_adapter :
public output_adapter_protocol<CharType>
14915 void write_characters(const CharType* s,
std::
size_t length)
override
14917 stream.write(s,
static_cast<std::streamsize
>(length));
14926template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14927class output_string_adapter :
public output_adapter_protocol<CharType>
14940 void write_characters(const CharType* s,
std::
size_t length)
override
14942 str.append(s, length);
14949template<
typename CharType,
typename StringType = std::basic_
string<CharType>>
14950class output_adapter
14953 template<
typename AllocatorType = std::allocator<CharType>>
14965 operator output_adapter_t<CharType>()
14971 output_adapter_t<CharType> oa =
nullptr;
14991template<
typename BasicJsonType,
typename CharType>
15017 case value_t::object:
15019 write_bson_object(*j.m_value.object);
15023 case value_t::null:
15024 case value_t::array:
15025 case value_t::string:
15026 case value_t::boolean:
15027 case value_t::number_integer:
15028 case value_t::number_unsigned:
15029 case value_t::number_float:
15030 case value_t::binary:
15031 case value_t::discarded:
15034 JSON_THROW(type_error::create(317,
concat(
"to serialize to BSON, top-level type must be object, but is ", j.type_name()), &j));
15046 case value_t::null:
15048 oa->write_character(to_char_type(0xF6));
15052 case value_t::boolean:
15054 oa->write_character(j.m_value.boolean
15055 ? to_char_type(0xF5)
15056 : to_char_type(0xF4));
15060 case value_t::number_integer:
15062 if (j.m_value.number_integer >= 0)
15067 if (j.m_value.number_integer <= 0x17)
15069 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15071 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
15073 oa->write_character(to_char_type(0x18));
15074 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15076 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
15078 oa->write_character(to_char_type(0x19));
15079 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15081 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
15083 oa->write_character(to_char_type(0x1A));
15084 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15088 oa->write_character(to_char_type(0x1B));
15089 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15096 const auto positive_number = -1 - j.m_value.number_integer;
15097 if (j.m_value.number_integer >= -24)
15099 write_number(
static_cast<std::uint8_t
>(0x20 + positive_number));
15101 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
15103 oa->write_character(to_char_type(0x38));
15104 write_number(
static_cast<std::uint8_t
>(positive_number));
15106 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
15108 oa->write_character(to_char_type(0x39));
15109 write_number(
static_cast<std::uint16_t
>(positive_number));
15111 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
15113 oa->write_character(to_char_type(0x3A));
15114 write_number(
static_cast<std::uint32_t
>(positive_number));
15118 oa->write_character(to_char_type(0x3B));
15119 write_number(
static_cast<std::uint64_t
>(positive_number));
15125 case value_t::number_unsigned:
15127 if (j.m_value.number_unsigned <= 0x17)
15129 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
15131 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15133 oa->write_character(to_char_type(0x18));
15134 write_number(
static_cast<std::uint8_t
>(j.m_value.number_unsigned));
15136 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15138 oa->write_character(to_char_type(0x19));
15139 write_number(
static_cast<std::uint16_t
>(j.m_value.number_unsigned));
15141 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15143 oa->write_character(to_char_type(0x1A));
15144 write_number(
static_cast<std::uint32_t
>(j.m_value.number_unsigned));
15148 oa->write_character(to_char_type(0x1B));
15149 write_number(
static_cast<std::uint64_t
>(j.m_value.number_unsigned));
15154 case value_t::number_float:
15156 if (std::isnan(j.m_value.number_float))
15159 oa->write_character(to_char_type(0xF9));
15160 oa->write_character(to_char_type(0x7E));
15161 oa->write_character(to_char_type(0x00));
15163 else if (std::isinf(j.m_value.number_float))
15166 oa->write_character(to_char_type(0xf9));
15167 oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC));
15168 oa->write_character(to_char_type(0x00));
15177 case value_t::string:
15180 const auto N = j.m_value.string->size();
15183 write_number(
static_cast<std::uint8_t
>(0x60 + N));
15185 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15187 oa->write_character(to_char_type(0x78));
15188 write_number(
static_cast<std::uint8_t
>(N));
15190 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15192 oa->write_character(to_char_type(0x79));
15193 write_number(
static_cast<std::uint16_t
>(N));
15195 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15197 oa->write_character(to_char_type(0x7A));
15198 write_number(
static_cast<std::uint32_t
>(N));
15201 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15203 oa->write_character(to_char_type(0x7B));
15204 write_number(
static_cast<std::uint64_t
>(N));
15209 oa->write_characters(
15210 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15211 j.m_value.string->size());
15215 case value_t::array:
15218 const auto N = j.m_value.array->size();
15221 write_number(
static_cast<std::uint8_t
>(0x80 + N));
15223 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15225 oa->write_character(to_char_type(0x98));
15226 write_number(
static_cast<std::uint8_t
>(N));
15228 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15230 oa->write_character(to_char_type(0x99));
15231 write_number(
static_cast<std::uint16_t
>(N));
15233 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15235 oa->write_character(to_char_type(0x9A));
15236 write_number(
static_cast<std::uint32_t
>(N));
15239 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15241 oa->write_character(to_char_type(0x9B));
15242 write_number(
static_cast<std::uint64_t
>(N));
15247 for (
const auto& el : *j.m_value.array)
15254 case value_t::binary:
15256 if (j.m_value.binary->has_subtype())
15258 if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint8_t>::max)())
15260 write_number(
static_cast<std::uint8_t
>(0xd8));
15261 write_number(
static_cast<std::uint8_t
>(j.m_value.binary->subtype()));
15263 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint16_t>::max)())
15265 write_number(
static_cast<std::uint8_t
>(0xd9));
15266 write_number(
static_cast<std::uint16_t
>(j.m_value.binary->subtype()));
15268 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint32_t>::max)())
15270 write_number(
static_cast<std::uint8_t
>(0xda));
15271 write_number(
static_cast<std::uint32_t
>(j.m_value.binary->subtype()));
15273 else if (j.m_value.binary->subtype() <= (std::numeric_limits<std::uint64_t>::max)())
15275 write_number(
static_cast<std::uint8_t
>(0xdb));
15276 write_number(
static_cast<std::uint64_t
>(j.m_value.binary->subtype()));
15281 const auto N = j.m_value.binary->size();
15284 write_number(
static_cast<std::uint8_t
>(0x40 + N));
15286 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15288 oa->write_character(to_char_type(0x58));
15289 write_number(
static_cast<std::uint8_t
>(N));
15291 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15293 oa->write_character(to_char_type(0x59));
15294 write_number(
static_cast<std::uint16_t
>(N));
15296 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15298 oa->write_character(to_char_type(0x5A));
15299 write_number(
static_cast<std::uint32_t
>(N));
15302 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15304 oa->write_character(to_char_type(0x5B));
15305 write_number(
static_cast<std::uint64_t
>(N));
15310 oa->write_characters(
15311 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15317 case value_t::object:
15320 const auto N = j.m_value.object->size();
15323 write_number(
static_cast<std::uint8_t
>(0xA0 + N));
15325 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15327 oa->write_character(to_char_type(0xB8));
15328 write_number(
static_cast<std::uint8_t
>(N));
15330 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15332 oa->write_character(to_char_type(0xB9));
15333 write_number(
static_cast<std::uint16_t
>(N));
15335 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15337 oa->write_character(to_char_type(0xBA));
15338 write_number(
static_cast<std::uint32_t
>(N));
15341 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
15343 oa->write_character(to_char_type(0xBB));
15344 write_number(
static_cast<std::uint64_t
>(N));
15349 for (
const auto& el : *j.m_value.object)
15351 write_cbor(el.first);
15352 write_cbor(el.second);
15357 case value_t::discarded:
15370 case value_t::null:
15372 oa->write_character(to_char_type(0xC0));
15376 case value_t::boolean:
15378 oa->write_character(j.m_value.boolean
15379 ? to_char_type(0xC3)
15380 : to_char_type(0xC2));
15384 case value_t::number_integer:
15386 if (j.m_value.number_integer >= 0)
15391 if (j.m_value.number_unsigned < 128)
15394 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15396 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15399 oa->write_character(to_char_type(0xCC));
15400 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15402 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15405 oa->write_character(to_char_type(0xCD));
15406 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15408 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15411 oa->write_character(to_char_type(0xCE));
15412 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15414 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15417 oa->write_character(to_char_type(0xCF));
15418 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15423 if (j.m_value.number_integer >= -32)
15426 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
15428 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() &&
15429 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
15432 oa->write_character(to_char_type(0xD0));
15433 write_number(
static_cast<std::int8_t
>(j.m_value.number_integer));
15435 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() &&
15436 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
15439 oa->write_character(to_char_type(0xD1));
15440 write_number(
static_cast<std::int16_t
>(j.m_value.number_integer));
15442 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() &&
15443 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
15446 oa->write_character(to_char_type(0xD2));
15447 write_number(
static_cast<std::int32_t
>(j.m_value.number_integer));
15449 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() &&
15450 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
15453 oa->write_character(to_char_type(0xD3));
15454 write_number(
static_cast<std::int64_t
>(j.m_value.number_integer));
15460 case value_t::number_unsigned:
15462 if (j.m_value.number_unsigned < 128)
15465 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15467 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
15470 oa->write_character(to_char_type(0xCC));
15471 write_number(
static_cast<std::uint8_t
>(j.m_value.number_integer));
15473 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
15476 oa->write_character(to_char_type(0xCD));
15477 write_number(
static_cast<std::uint16_t
>(j.m_value.number_integer));
15479 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
15482 oa->write_character(to_char_type(0xCE));
15483 write_number(
static_cast<std::uint32_t
>(j.m_value.number_integer));
15485 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
15488 oa->write_character(to_char_type(0xCF));
15489 write_number(
static_cast<std::uint64_t
>(j.m_value.number_integer));
15494 case value_t::number_float:
15500 case value_t::string:
15503 const auto N = j.m_value.string->size();
15507 write_number(
static_cast<std::uint8_t
>(0xA0 | N));
15509 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
15512 oa->write_character(to_char_type(0xD9));
15513 write_number(
static_cast<std::uint8_t
>(N));
15515 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15518 oa->write_character(to_char_type(0xDA));
15519 write_number(
static_cast<std::uint16_t
>(N));
15521 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15524 oa->write_character(to_char_type(0xDB));
15525 write_number(
static_cast<std::uint32_t
>(N));
15529 oa->write_characters(
15530 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15531 j.m_value.string->size());
15535 case value_t::array:
15538 const auto N = j.m_value.array->size();
15542 write_number(
static_cast<std::uint8_t
>(0x90 | N));
15544 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15547 oa->write_character(to_char_type(0xDC));
15548 write_number(
static_cast<std::uint16_t
>(N));
15550 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15553 oa->write_character(to_char_type(0xDD));
15554 write_number(
static_cast<std::uint32_t
>(N));
15558 for (
const auto& el : *j.m_value.array)
15565 case value_t::binary:
15569 const bool use_ext = j.m_value.binary->has_subtype();
15572 const auto N = j.m_value.binary->size();
15573 if (N <= (std::numeric_limits<std::uint8_t>::max)())
15575 std::uint8_t output_type{};
15582 output_type = 0xD4;
15585 output_type = 0xD5;
15588 output_type = 0xD6;
15591 output_type = 0xD7;
15594 output_type = 0xD8;
15597 output_type = 0xC7;
15605 output_type = 0xC4;
15609 oa->write_character(to_char_type(output_type));
15612 write_number(
static_cast<std::uint8_t
>(N));
15615 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15617 const std::uint8_t output_type = use_ext
15621 oa->write_character(to_char_type(output_type));
15622 write_number(
static_cast<std::uint16_t
>(N));
15624 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15626 const std::uint8_t output_type = use_ext
15630 oa->write_character(to_char_type(output_type));
15631 write_number(
static_cast<std::uint32_t
>(N));
15637 write_number(
static_cast<std::int8_t
>(j.m_value.binary->subtype()));
15641 oa->write_characters(
15642 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15648 case value_t::object:
15651 const auto N = j.m_value.object->size();
15655 write_number(
static_cast<std::uint8_t
>(0x80 | (N & 0xF)));
15657 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
15660 oa->write_character(to_char_type(0xDE));
15661 write_number(
static_cast<std::uint16_t
>(N));
15663 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
15666 oa->write_character(to_char_type(0xDF));
15667 write_number(
static_cast<std::uint32_t
>(N));
15671 for (
const auto& el : *j.m_value.object)
15673 write_msgpack(el.first);
15674 write_msgpack(el.second);
15679 case value_t::discarded:
15693 const bool use_type,
const bool add_prefix =
true,
15694 const bool use_bjdata =
false)
15698 case value_t::null:
15702 oa->write_character(to_char_type(
'Z'));
15707 case value_t::boolean:
15711 oa->write_character(j.m_value.boolean
15712 ? to_char_type(
'T')
15713 : to_char_type(
'F'));
15718 case value_t::number_integer:
15720 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix, use_bjdata);
15724 case value_t::number_unsigned:
15726 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix, use_bjdata);
15730 case value_t::number_float:
15732 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix, use_bjdata);
15736 case value_t::string:
15740 oa->write_character(to_char_type(
'S'));
15742 write_number_with_ubjson_prefix(j.m_value.string->size(),
true, use_bjdata);
15743 oa->write_characters(
15744 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
15745 j.m_value.string->size());
15749 case value_t::array:
15753 oa->write_character(to_char_type(
'['));
15756 bool prefix_required =
true;
15757 if (use_type && !j.m_value.array->empty())
15760 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15761 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
15762 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15764 return ubjson_prefix(v, use_bjdata) == first_prefix;
15767 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15769 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15771 prefix_required =
false;
15772 oa->write_character(to_char_type(
'$'));
15773 oa->write_character(first_prefix);
15779 oa->write_character(to_char_type(
'#'));
15780 write_number_with_ubjson_prefix(j.m_value.array->size(),
true, use_bjdata);
15783 for (
const auto& el : *j.m_value.array)
15785 write_ubjson(el, use_count, use_type, prefix_required, use_bjdata);
15790 oa->write_character(to_char_type(
']'));
15796 case value_t::binary:
15800 oa->write_character(to_char_type(
'['));
15803 if (use_type && !j.m_value.binary->empty())
15806 oa->write_character(to_char_type(
'$'));
15807 oa->write_character(
'U');
15812 oa->write_character(to_char_type(
'#'));
15813 write_number_with_ubjson_prefix(j.m_value.binary->size(),
true, use_bjdata);
15818 oa->write_characters(
15819 reinterpret_cast<const CharType*
>(j.m_value.binary->data()),
15820 j.m_value.binary->size());
15824 for (
size_t i = 0; i < j.m_value.binary->size(); ++i)
15826 oa->write_character(to_char_type(
'U'));
15827 oa->write_character(j.m_value.binary->data()[i]);
15833 oa->write_character(to_char_type(
']'));
15839 case value_t::object:
15841 if (use_bjdata && j.m_value.object->size() == 3 && j.m_value.object->find(
"_ArrayType_") != j.m_value.object->end() && j.m_value.object->find(
"_ArraySize_") != j.m_value.object->end() && j.m_value.object->find(
"_ArrayData_") != j.m_value.object->end())
15843 if (!write_bjdata_ndarray(*j.m_value.object, use_count, use_type))
15851 oa->write_character(to_char_type(
'{'));
15854 bool prefix_required =
true;
15855 if (use_type && !j.m_value.object->empty())
15858 const CharType first_prefix = ubjson_prefix(j.front(), use_bjdata);
15859 const bool same_prefix = std::all_of(j.begin(), j.end(),
15860 [
this, first_prefix, use_bjdata](
const BasicJsonType & v)
15862 return ubjson_prefix(v, use_bjdata) == first_prefix;
15865 std::vector<CharType> bjdx = {
'[',
'{',
'S',
'H',
'T',
'F',
'N',
'Z'};
15867 if (same_prefix && !(use_bjdata && std::find(bjdx.begin(), bjdx.end(), first_prefix) != bjdx.end()))
15869 prefix_required =
false;
15870 oa->write_character(to_char_type(
'$'));
15871 oa->write_character(first_prefix);
15877 oa->write_character(to_char_type(
'#'));
15878 write_number_with_ubjson_prefix(j.m_value.object->size(),
true, use_bjdata);
15881 for (
const auto& el : *j.m_value.object)
15883 write_number_with_ubjson_prefix(el.first.size(),
true, use_bjdata);
15884 oa->write_characters(
15885 reinterpret_cast<const CharType*
>(el.first.c_str()),
15887 write_ubjson(el.second, use_count, use_type, prefix_required, use_bjdata);
15892 oa->write_character(to_char_type(
'}'));
15898 case value_t::discarded:
15915 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
15918 JSON_THROW(out_of_range::create(409,
concat(
"BSON key cannot contain code point U+0000 (at byte ", std::to_string(it),
")"), &j));
15919 static_cast<void>(j);
15922 return 1ul + name.size() + 1u;
15929 const std::uint8_t element_type)
15931 oa->write_character(to_char_type(element_type));
15932 oa->write_characters(
15933 reinterpret_cast<const CharType*
>(name.c_str()),
15943 write_bson_entry_header(name, 0x08);
15944 oa->write_character(
value ? to_char_type(0x01) : to_char_type(0x00));
15951 const double value)
15953 write_bson_entry_header(name, 0x01);
15954 write_number<double>(
value,
true);
15962 return sizeof(std::int32_t) +
value.size() + 1ul;
15971 write_bson_entry_header(name, 0x02);
15973 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size() + 1ul),
true);
15974 oa->write_characters(
15975 reinterpret_cast<const CharType*
>(
value.c_str()),
15984 write_bson_entry_header(name, 0x0A);
15992 return (std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)()
15993 ?
sizeof(std::int32_t)
15994 :
sizeof(std::int64_t);
16001 const std::int64_t value)
16003 if ((std::numeric_limits<std::int32_t>::min)() <=
value &&
value <= (std::numeric_limits<std::int32_t>::max)())
16005 write_bson_entry_header(name, 0x10);
16006 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value),
true);
16010 write_bson_entry_header(name, 0x12);
16011 write_number<std::int64_t>(
static_cast<std::int64_t
>(
value),
true);
16020 return (
value <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16021 ?
sizeof(std::int32_t)
16022 :
sizeof(std::int64_t);
16029 const BasicJsonType& j)
16031 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16033 write_bson_entry_header(name, 0x10 );
16034 write_number<std::int32_t>(
static_cast<std::int32_t
>(j.m_value.number_unsigned),
true);
16036 else if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16038 write_bson_entry_header(name, 0x12 );
16039 write_number<std::int64_t>(
static_cast<std::int64_t
>(j.m_value.number_unsigned),
true);
16043 JSON_THROW(out_of_range::create(407,
concat(
"integer number ", std::to_string(j.m_value.number_unsigned),
" cannot be represented by BSON as it does not fit int64"), &j));
16051 const typename BasicJsonType::object_t& value)
16053 write_bson_entry_header(name, 0x03);
16054 write_bson_object(
value);
16064 const std::size_t embedded_document_size = std::accumulate(std::begin(
value), std::end(
value),
static_cast<std::size_t>(0), [&array_index](
std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
16066 return result + calc_bson_element_size(std::to_string(array_index++), el);
16069 return sizeof(std::int32_t) + embedded_document_size + 1ul;
16077 return sizeof(std::int32_t) +
value.size() + 1ul;
16084 const typename BasicJsonType::array_t& value)
16086 write_bson_entry_header(name, 0x04);
16087 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_array_size(
value)),
true);
16091 for (
const auto& el :
value)
16093 write_bson_element(std::to_string(array_index++), el);
16096 oa->write_character(to_char_type(0x00));
16105 write_bson_entry_header(name, 0x05);
16107 write_number<std::int32_t>(
static_cast<std::int32_t
>(
value.size()),
true);
16108 write_number(
value.has_subtype() ?
static_cast<std::uint8_t
>(
value.subtype()) :
static_cast<std::uint8_t
>(0x00));
16110 oa->write_characters(
reinterpret_cast<const CharType*
>(
value.data()),
value.size());
16118 const BasicJsonType& j)
16120 const auto header_size = calc_bson_entry_header_size(name, j);
16123 case value_t::object:
16124 return header_size + calc_bson_object_size(*j.m_value.object);
16126 case value_t::array:
16127 return header_size + calc_bson_array_size(*j.m_value.array);
16129 case value_t::binary:
16130 return header_size + calc_bson_binary_size(*j.m_value.binary);
16132 case value_t::boolean:
16133 return header_size + 1ul;
16135 case value_t::number_float:
16136 return header_size + 8ul;
16138 case value_t::number_integer:
16139 return header_size + calc_bson_integer_size(j.m_value.number_integer);
16141 case value_t::number_unsigned:
16142 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
16144 case value_t::string:
16145 return header_size + calc_bson_string_size(*j.m_value.string);
16147 case value_t::null:
16148 return header_size + 0ul;
16151 case value_t::discarded:
16166 const BasicJsonType& j)
16170 case value_t::object:
16171 return write_bson_object_entry(name, *j.m_value.object);
16173 case value_t::array:
16174 return write_bson_array(name, *j.m_value.array);
16176 case value_t::binary:
16177 return write_bson_binary(name, *j.m_value.binary);
16179 case value_t::boolean:
16180 return write_bson_boolean(name, j.m_value.boolean);
16182 case value_t::number_float:
16183 return write_bson_double(name, j.m_value.number_float);
16185 case value_t::number_integer:
16186 return write_bson_integer(name, j.m_value.number_integer);
16188 case value_t::number_unsigned:
16189 return write_bson_unsigned(name, j);
16191 case value_t::string:
16192 return write_bson_string(name, *j.m_value.string);
16194 case value_t::null:
16195 return write_bson_null(name);
16198 case value_t::discarded:
16215 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
16217 return result += calc_bson_element_size(el.first, el.second);
16220 return sizeof(std::int32_t) + document_size + 1ul;
16229 write_number<std::int32_t>(
static_cast<std::int32_t
>(calc_bson_object_size(
value)),
true);
16231 for (
const auto& el :
value)
16233 write_bson_element(el.first, el.second);
16236 oa->write_character(to_char_type(0x00));
16245 return to_char_type(0xFA);
16250 return to_char_type(0xFB);
16259 return to_char_type(0xCA);
16264 return to_char_type(0xCB);
16272 template<
typename NumberType,
typename std::enable_if<
16273 std::is_floating_point<NumberType>::value,
int>::type = 0>
16275 const bool add_prefix,
16276 const bool use_bjdata)
16280 oa->write_character(get_ubjson_float_prefix(n));
16282 write_number(n, use_bjdata);
16286 template<
typename NumberType,
typename std::enable_if<
16287 std::is_unsigned<NumberType>::value,
int>::type = 0>
16289 const bool add_prefix,
16290 const bool use_bjdata)
16292 if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16296 oa->write_character(to_char_type(
'i'));
16298 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16300 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
16304 oa->write_character(to_char_type(
'U'));
16306 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16308 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16312 oa->write_character(to_char_type(
'I'));
16314 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16316 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint16_t>::max)()))
16320 oa->write_character(to_char_type(
'u'));
16322 write_number(
static_cast<std::uint16_t
>(n), use_bjdata);
16324 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16328 oa->write_character(to_char_type(
'l'));
16330 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16332 else if (use_bjdata && n <=
static_cast<uint64_t
>((std::numeric_limits<uint32_t>::max)()))
16336 oa->write_character(to_char_type(
'm'));
16338 write_number(
static_cast<std::uint32_t
>(n), use_bjdata);
16340 else if (n <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16344 oa->write_character(to_char_type(
'L'));
16346 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16348 else if (use_bjdata && n <= (std::numeric_limits<uint64_t>::max)())
16352 oa->write_character(to_char_type(
'M'));
16354 write_number(
static_cast<std::uint64_t
>(n), use_bjdata);
16360 oa->write_character(to_char_type(
'H'));
16363 const auto number = BasicJsonType(n).dump();
16364 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16367 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16373 template <
typename NumberType,
typename std::enable_if <
16374 std::is_signed<NumberType>::value&&
16375 !std::is_floating_point<NumberType>::value,
int >::type = 0 >
16377 const bool add_prefix,
16378 const bool use_bjdata)
16380 if ((std::numeric_limits<std::int8_t>::min)() <= n && n <= (std::numeric_limits<std::int8_t>::max)())
16384 oa->write_character(to_char_type(
'i'));
16386 write_number(
static_cast<std::int8_t
>(n), use_bjdata);
16388 else if (
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16392 oa->write_character(to_char_type(
'U'));
16394 write_number(
static_cast<std::uint8_t
>(n), use_bjdata);
16396 else if ((std::numeric_limits<std::int16_t>::min)() <= n && n <= (std::numeric_limits<std::int16_t>::max)())
16400 oa->write_character(to_char_type(
'I'));
16402 write_number(
static_cast<std::int16_t
>(n), use_bjdata);
16404 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint16_t>::max)())))
16408 oa->write_character(to_char_type(
'u'));
16410 write_number(
static_cast<uint16_t
>(n), use_bjdata);
16412 else if ((std::numeric_limits<std::int32_t>::min)() <= n && n <= (std::numeric_limits<std::int32_t>::max)())
16416 oa->write_character(to_char_type(
'l'));
16418 write_number(
static_cast<std::int32_t
>(n), use_bjdata);
16420 else if (use_bjdata && (
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::min)()) <= n && n <=
static_cast<std::int64_t
>((std::numeric_limits<std::uint32_t>::max)())))
16424 oa->write_character(to_char_type(
'm'));
16426 write_number(
static_cast<uint32_t
>(n), use_bjdata);
16428 else if ((std::numeric_limits<std::int64_t>::min)() <= n && n <= (std::numeric_limits<std::int64_t>::max)())
16432 oa->write_character(to_char_type(
'L'));
16434 write_number(
static_cast<std::int64_t
>(n), use_bjdata);
16441 oa->write_character(to_char_type(
'H'));
16444 const auto number = BasicJsonType(n).dump();
16445 write_number_with_ubjson_prefix(number.size(),
true, use_bjdata);
16448 oa->write_character(to_char_type(
static_cast<std::uint8_t
>(number[i])));
16457 CharType
ubjson_prefix(
const BasicJsonType& j,
const bool use_bjdata)
const noexcept
16461 case value_t::null:
16464 case value_t::boolean:
16465 return j.m_value.boolean ?
'T' :
'F';
16467 case value_t::number_integer:
16469 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
16473 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
16477 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
16481 if (use_bjdata && ((std::numeric_limits<std::uint16_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)()))
16485 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
16489 if (use_bjdata && ((std::numeric_limits<std::uint32_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)()))
16493 if ((std::numeric_limits<std::int64_t>::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
16501 case value_t::number_unsigned:
16503 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int8_t>::max)()))
16507 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint8_t>::max)()))
16511 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int16_t>::max)()))
16515 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint16_t>::max)()))
16519 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int32_t>::max)()))
16523 if (use_bjdata && j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::uint32_t>::max)()))
16527 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t
>((std::numeric_limits<std::int64_t>::max)()))
16531 if (use_bjdata && j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
16539 case value_t::number_float:
16540 return get_ubjson_float_prefix(j.m_value.number_float);
16542 case value_t::string:
16545 case value_t::array:
16546 case value_t::binary:
16549 case value_t::object:
16552 case value_t::discarded:
16573 std::map<string_t, CharType> bjdtype = {{
"uint8",
'U'}, {
"int8",
'i'}, {
"uint16",
'u'}, {
"int16",
'I'},
16574 {
"uint32",
'm'}, {
"int32",
'l'}, {
"uint64",
'M'}, {
"int64",
'L'}, {
"single",
'd'}, {
"double",
'D'}, {
"char",
'C'}
16579 if (it == bjdtype.end())
16583 CharType dtype = it->second;
16585 key =
"_ArraySize_";
16587 for (
const auto& el :
value.at(
key))
16589 len *=
static_cast<std::size_t>(el.m_value.number_unsigned);
16592 key =
"_ArrayData_";
16598 oa->write_character(
'[');
16599 oa->write_character(
'$');
16600 oa->write_character(dtype);
16601 oa->write_character(
'#');
16603 key =
"_ArraySize_";
16604 write_ubjson(
value.at(
key), use_count, use_type,
true,
true);
16606 key =
"_ArrayData_";
16607 if (dtype ==
'U' || dtype ==
'C')
16609 for (
const auto& el :
value.at(
key))
16611 write_number(
static_cast<std::uint8_t
>(el.m_value.number_unsigned),
true);
16614 else if (dtype ==
'i')
16616 for (
const auto& el :
value.at(
key))
16618 write_number(
static_cast<std::int8_t
>(el.m_value.number_integer),
true);
16621 else if (dtype ==
'u')
16623 for (
const auto& el :
value.at(
key))
16625 write_number(
static_cast<std::uint16_t
>(el.m_value.number_unsigned),
true);
16628 else if (dtype ==
'I')
16630 for (
const auto& el :
value.at(
key))
16632 write_number(
static_cast<std::int16_t
>(el.m_value.number_integer),
true);
16635 else if (dtype ==
'm')
16637 for (
const auto& el :
value.at(
key))
16639 write_number(
static_cast<std::uint32_t
>(el.m_value.number_unsigned),
true);
16642 else if (dtype ==
'l')
16644 for (
const auto& el :
value.at(
key))
16646 write_number(
static_cast<std::int32_t
>(el.m_value.number_integer),
true);
16649 else if (dtype ==
'M')
16651 for (
const auto& el :
value.at(
key))
16653 write_number(
static_cast<std::uint64_t
>(el.m_value.number_unsigned),
true);
16656 else if (dtype ==
'L')
16658 for (
const auto& el :
value.at(
key))
16660 write_number(
static_cast<std::int64_t
>(el.m_value.number_integer),
true);
16663 else if (dtype ==
'd')
16665 for (
const auto& el :
value.at(
key))
16667 write_number(
static_cast<float>(el.m_value.number_float),
true);
16670 else if (dtype ==
'D')
16672 for (
const auto& el :
value.at(
key))
16674 write_number(
static_cast<double>(el.m_value.number_float),
true);
16697 template<
typename NumberType>
16701 std::array<CharType,
sizeof(NumberType)> vec{};
16702 std::memcpy(vec.data(), &n,
sizeof(NumberType));
16705 if (is_little_endian != OutputIsLittleEndian)
16708 std::reverse(vec.begin(), vec.end());
16711 oa->write_characters(vec.data(),
sizeof(NumberType));
16717#pragma GCC diagnostic push
16718#pragma GCC diagnostic ignored "-Wfloat-equal"
16720 if (
static_cast<double>(n) >=
static_cast<double>(std::numeric_limits<float>::lowest()) &&
16721 static_cast<double>(n) <=
static_cast<double>((std::numeric_limits<float>::max)()) &&
16722 static_cast<double>(
static_cast<float>(n)) ==
static_cast<double>(n))
16725 ? get_cbor_float_prefix(
static_cast<float>(n))
16726 : get_msgpack_float_prefix(
static_cast<float>(n)));
16727 write_number(
static_cast<float>(n));
16732 ? get_cbor_float_prefix(n)
16733 : get_msgpack_float_prefix(n));
16737#pragma GCC diagnostic pop
16746 template <
typename C = CharType,
16747 enable_if_t < std::is_signed<C>::value && std::is_signed<char>::value > * =
nullptr >
16750 return *
reinterpret_cast<char*
>(&x);
16753 template <
typename C = CharType,
16754 enable_if_t < std::is_signed<C>::value && std::is_unsigned<char>::value > * =
nullptr >
16757 static_assert(
sizeof(std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
16758 static_assert(std::is_trivial<CharType>::value,
"CharType must be trivial");
16760 std::memcpy(&result, &x,
sizeof(x));
16764 template<
typename C = CharType,
16765 enable_if_t<std::is_unsigned<C>::value>* =
nullptr>
16771 template <
typename InputCharType,
typename C = CharType,
16773 std::is_signed<C>::value &&
16774 std::is_signed<char>::value &&
16775 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
16787 output_adapter_t<CharType> oa =
nullptr;
16807#include <algorithm>
16817#include <type_traits>
16837#include <type_traits>
16868template<
typename Target,
typename Source>
16871 static_assert(
sizeof(Target) ==
sizeof(Source),
"size mismatch");
16874 std::memcpy(&target, &source,
sizeof(Source));
16880 static constexpr int kPrecision = 64;
16882 std::uint64_t f = 0;
16885 constexpr diyfp(std::uint64_t f_,
int e_) noexcept : f(f_), e(e_) {}
16896 return {x.f - y.f, x.e};
16905 static_assert(kPrecision == 64,
"internal error");
16930 const std::uint64_t u_lo = x.f & 0xFFFFFFFFu;
16931 const std::uint64_t u_hi = x.f >> 32u;
16932 const std::uint64_t v_lo = y.f & 0xFFFFFFFFu;
16933 const std::uint64_t v_hi = y.f >> 32u;
16935 const std::uint64_t p0 = u_lo * v_lo;
16936 const std::uint64_t p1 = u_lo * v_hi;
16937 const std::uint64_t p2 = u_hi * v_lo;
16938 const std::uint64_t p3 = u_hi * v_hi;
16940 const std::uint64_t p0_hi = p0 >> 32u;
16941 const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu;
16942 const std::uint64_t p1_hi = p1 >> 32u;
16943 const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu;
16944 const std::uint64_t p2_hi = p2 >> 32u;
16946 std::uint64_t Q = p0_hi + p1_lo + p2_lo;
16957 Q += std::uint64_t{1} << (64u - 32u - 1u);
16959 const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u);
16961 return {h, x.e + y.e + 64};
16972 while ((x.f >> 63u) == 0)
16987 const int delta = x.e - target_exponent;
16992 return {x.f << delta, target_exponent};
17009template<
typename FloatType>
17010boundaries compute_boundaries(FloatType value)
17022 static_assert(std::numeric_limits<FloatType>::is_iec559,
17023 "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
17025 constexpr int kPrecision = std::numeric_limits<FloatType>::digits;
17026 constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
17027 constexpr int kMinExp = 1 - kBias;
17028 constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1);
17030 using bits_type =
typename std::conditional<kPrecision == 24, std::uint32_t, std::uint64_t >::type;
17032 const auto bits =
static_cast<std::uint64_t
>(reinterpret_bits<bits_type>(value));
17033 const std::uint64_t E = bits >> (kPrecision - 1);
17034 const std::uint64_t F = bits & (kHiddenBit - 1);
17036 const bool is_denormal = E == 0;
17037 const diyfp v = is_denormal
17038 ? diyfp(F, kMinExp)
17039 : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
17062 const bool lower_boundary_is_closer = F == 0 && E > 1;
17063 const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
17064 const diyfp m_minus = lower_boundary_is_closer
17065 ? diyfp(4 * v.f - 1, v.e - 2)
17066 : diyfp(2 * v.f - 1, v.e - 1);
17069 const diyfp w_plus = diyfp::normalize(m_plus);
17072 const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e);
17074 return {diyfp::normalize(v), w_minus, w_plus};
17132constexpr int kAlpha = -60;
17133constexpr int kGamma = -32;
17201 constexpr int kCachedPowersMinDecExp = -300;
17202 constexpr int kCachedPowersDecStep = 8;
17204 static constexpr std::array<cached_power, 79> kCachedPowers =
17207 { 0xAB70FE17C79AC6CA, -1060, -300 },
17208 { 0xFF77B1FCBEBCDC4F, -1034, -292 },
17209 { 0xBE5691EF416BD60C, -1007, -284 },
17210 { 0x8DD01FAD907FFC3C, -980, -276 },
17211 { 0xD3515C2831559A83, -954, -268 },
17212 { 0x9D71AC8FADA6C9B5, -927, -260 },
17213 { 0xEA9C227723EE8BCB, -901, -252 },
17214 { 0xAECC49914078536D, -874, -244 },
17215 { 0x823C12795DB6CE57, -847, -236 },
17216 { 0xC21094364DFB5637, -821, -228 },
17217 { 0x9096EA6F3848984F, -794, -220 },
17218 { 0xD77485CB25823AC7, -768, -212 },
17219 { 0xA086CFCD97BF97F4, -741, -204 },
17220 { 0xEF340A98172AACE5, -715, -196 },
17221 { 0xB23867FB2A35B28E, -688, -188 },
17222 { 0x84C8D4DFD2C63F3B, -661, -180 },
17223 { 0xC5DD44271AD3CDBA, -635, -172 },
17224 { 0x936B9FCEBB25C996, -608, -164 },
17225 { 0xDBAC6C247D62A584, -582, -156 },
17226 { 0xA3AB66580D5FDAF6, -555, -148 },
17227 { 0xF3E2F893DEC3F126, -529, -140 },
17228 { 0xB5B5ADA8AAFF80B8, -502, -132 },
17229 { 0x87625F056C7C4A8B, -475, -124 },
17230 { 0xC9BCFF6034C13053, -449, -116 },
17231 { 0x964E858C91BA2655, -422, -108 },
17232 { 0xDFF9772470297EBD, -396, -100 },
17233 { 0xA6DFBD9FB8E5B88F, -369, -92 },
17234 { 0xF8A95FCF88747D94, -343, -84 },
17235 { 0xB94470938FA89BCF, -316, -76 },
17236 { 0x8A08F0F8BF0F156B, -289, -68 },
17237 { 0xCDB02555653131B6, -263, -60 },
17238 { 0x993FE2C6D07B7FAC, -236, -52 },
17239 { 0xE45C10C42A2B3B06, -210, -44 },
17240 { 0xAA242499697392D3, -183, -36 },
17241 { 0xFD87B5F28300CA0E, -157, -28 },
17242 { 0xBCE5086492111AEB, -130, -20 },
17243 { 0x8CBCCC096F5088CC, -103, -12 },
17244 { 0xD1B71758E219652C, -77, -4 },
17245 { 0x9C40000000000000, -50, 4 },
17246 { 0xE8D4A51000000000, -24, 12 },
17247 { 0xAD78EBC5AC620000, 3, 20 },
17248 { 0x813F3978F8940984, 30, 28 },
17249 { 0xC097CE7BC90715B3, 56, 36 },
17250 { 0x8F7E32CE7BEA5C70, 83, 44 },
17251 { 0xD5D238A4ABE98068, 109, 52 },
17252 { 0x9F4F2726179A2245, 136, 60 },
17253 { 0xED63A231D4C4FB27, 162, 68 },
17254 { 0xB0DE65388CC8ADA8, 189, 76 },
17255 { 0x83C7088E1AAB65DB, 216, 84 },
17256 { 0xC45D1DF942711D9A, 242, 92 },
17257 { 0x924D692CA61BE758, 269, 100 },
17258 { 0xDA01EE641A708DEA, 295, 108 },
17259 { 0xA26DA3999AEF774A, 322, 116 },
17260 { 0xF209787BB47D6B85, 348, 124 },
17261 { 0xB454E4A179DD1877, 375, 132 },
17262 { 0x865B86925B9BC5C2, 402, 140 },
17263 { 0xC83553C5C8965D3D, 428, 148 },
17264 { 0x952AB45CFA97A0B3, 455, 156 },
17265 { 0xDE469FBD99A05FE3, 481, 164 },
17266 { 0xA59BC234DB398C25, 508, 172 },
17267 { 0xF6C69A72A3989F5C, 534, 180 },
17268 { 0xB7DCBF5354E9BECE, 561, 188 },
17269 { 0x88FCF317F22241E2, 588, 196 },
17270 { 0xCC20CE9BD35C78A5, 614, 204 },
17271 { 0x98165AF37B2153DF, 641, 212 },
17272 { 0xE2A0B5DC971F303A, 667, 220 },
17273 { 0xA8D9D1535CE3B396, 694, 228 },
17274 { 0xFB9B7CD9A4A7443C, 720, 236 },
17275 { 0xBB764C4CA7A44410, 747, 244 },
17276 { 0x8BAB8EEFB6409C1A, 774, 252 },
17277 { 0xD01FEF10A657842C, 800, 260 },
17278 { 0x9B10A4E5E9913129, 827, 268 },
17279 { 0xE7109BFBA19C0C9D, 853, 276 },
17280 { 0xAC2820D9623BF429, 880, 284 },
17281 { 0x80444B5E7AA7CF85, 907, 292 },
17282 { 0xBF21E44003ACDD2D, 933, 300 },
17283 { 0x8E679C2F5E44FF8F, 960, 308 },
17284 { 0xD433179D9C8CB841, 986, 316 },
17285 { 0x9E19DB92B4E31BA9, 1013, 324 },
17295 const int f =
kAlpha - e - 1;
17296 const int k = (f * 78913) / (1 << 18) +
static_cast<int>(f > 0);
17298 const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep;
17302 const cached_power cached = kCachedPowers[
static_cast<std::size_t>(index)];
17316 if (n >= 1000000000)
17318 pow10 = 1000000000;
17322 if (n >= 100000000)
17367inline void grisu2_round(
char* buf,
int len, std::uint64_t dist, std::uint64_t delta,
17368 std::uint64_t rest, std::uint64_t ten_k)
17395 && delta - rest >= ten_k
17396 && (rest + ten_k < dist || dist - rest > rest + ten_k - dist))
17408inline void grisu2_digit_gen(
char* buffer,
int& length,
int& decimal_exponent,
17409 diyfp M_minus, diyfp w, diyfp M_plus)
17411 static_assert(
kAlpha >= -60,
"internal error");
17412 static_assert(
kGamma <= -32,
"internal error");
17429 std::uint64_t delta = diyfp::sub(M_plus, M_minus).f;
17430 std::uint64_t dist = diyfp::sub(M_plus, w ).f;
17439 const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e);
17441 auto p1 =
static_cast<std::uint32_t
>(M_plus.f >> -one.e);
17442 std::uint64_t p2 = M_plus.f & (one.f - 1);
17450 std::uint32_t pow10{};
17478 const std::uint32_t d = p1 / pow10;
17479 const std::uint32_t r = p1 % pow10;
17485 buffer[length++] =
static_cast<char>(
'0' + d);
17504 const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2;
17509 decimal_exponent += n;
17520 const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e;
17521 grisu2_round(buffer, length, dist, delta, rest, ten_n);
17582 JSON_ASSERT(p2 <= (std::numeric_limits<std::uint64_t>::max)() / 10);
17584 const std::uint64_t d = p2 >> -one.e;
17585 const std::uint64_t r = p2 & (one.f - 1);
17592 buffer[length++] =
static_cast<char>(
'0' + d);
17617 decimal_exponent -= m;
17625 const std::uint64_t ten_m = one.f;
17649inline
void grisu2(
char* buf,
int& len,
int& decimal_exponent,
17650 diyfp m_minus, diyfp v, diyfp m_plus)
17666 const diyfp c_minus_k(cached.f, cached.e);
17669 const diyfp w = diyfp::mul(v, c_minus_k);
17670 const diyfp w_minus = diyfp::mul(m_minus, c_minus_k);
17671 const diyfp w_plus = diyfp::mul(m_plus, c_minus_k);
17694 const diyfp M_minus(w_minus.f + 1, w_minus.e);
17695 const diyfp M_plus (w_plus.f - 1, w_plus.e );
17697 decimal_exponent = -cached.k;
17707template<
typename FloatType>
17709void grisu2(
char* buf,
int& len,
int& decimal_exponent, FloatType value)
17711 static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
17712 "internal error: not enough precision");
17739 grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus);
17749inline
char* append_exponent(
char* buf,
int e)
17764 auto k =
static_cast<std::uint32_t
>(e);
17770 *buf++ =
static_cast<char>(
'0' + k);
17774 *buf++ =
static_cast<char>(
'0' + k / 10);
17776 *buf++ =
static_cast<char>(
'0' + k);
17780 *buf++ =
static_cast<char>(
'0' + k / 100);
17782 *buf++ =
static_cast<char>(
'0' + k / 10);
17784 *buf++ =
static_cast<char>(
'0' + k);
17801inline
char* format_buffer(
char* buf,
int len,
int decimal_exponent,
17802 int min_exp,
int max_exp)
17808 const int n = len + decimal_exponent;
17814 if (k <= n && n <= max_exp)
17819 std::memset(buf + k,
'0',
static_cast<size_t>(n) -
static_cast<size_t>(k));
17823 return buf + (
static_cast<size_t>(n) + 2);
17826 if (0 < n && n <= max_exp)
17833 std::memmove(buf + (
static_cast<size_t>(n) + 1), buf + n,
static_cast<size_t>(k) -
static_cast<size_t>(n));
17835 return buf + (
static_cast<size_t>(k) + 1U);
17838 if (min_exp < n && n <= 0)
17843 std::memmove(buf + (2 +
static_cast<size_t>(-n)), buf,
static_cast<size_t>(k));
17846 std::memset(buf + 2,
'0',
static_cast<size_t>(-n));
17847 return buf + (2U +
static_cast<size_t>(-n) +
static_cast<size_t>(k));
17862 std::memmove(buf + 2, buf + 1,
static_cast<size_t>(k) - 1);
17864 buf += 1 +
static_cast<size_t>(k);
17883template<
typename FloatType>
17886char* to_chars(
char* first, const
char* last, FloatType value)
17888 static_cast<void>(last);
17892 if (std::signbit(value))
17899#pragma GCC diagnostic push
17900#pragma GCC diagnostic ignored "-Wfloat-equal"
17911#pragma GCC diagnostic pop
17914 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10);
17921 int decimal_exponent = 0;
17922 dtoa_impl::grisu2(first, len, decimal_exponent, value);
17924 JSON_ASSERT(len <= std::numeric_limits<FloatType>::max_digits10);
17927 constexpr int kMinExp = -4;
17929 constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
17932 JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
17933 JSON_ASSERT(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
17935 return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
17972template<
typename BasicJsonType>
17980 static constexpr std::uint8_t UTF8_ACCEPT = 0;
17981 static constexpr std::uint8_t UTF8_REJECT = 1;
17992 , loc(
std::localeconv())
17993 , thousands_sep(loc->thousands_sep == nullptr ?
'\0' :
std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
17994 , decimal_point(loc->decimal_point == nullptr ?
'\0' :
std::char_traits<char>::to_char_type(* (loc->decimal_point)))
17995 , indent_char(ichar)
17996 , indent_string(512, indent_char)
17997 , error_handler(error_handler_)
18030 const bool pretty_print,
18031 const bool ensure_ascii,
18032 const unsigned int indent_step,
18033 const unsigned int current_indent = 0)
18035 switch (val.m_type)
18037 case value_t::object:
18039 if (val.m_value.object->empty())
18041 o->write_characters(
"{}", 2);
18047 o->write_characters(
"{\n", 2);
18050 const auto new_indent = current_indent + indent_step;
18053 indent_string.resize(indent_string.size() * 2,
' ');
18057 auto i = val.m_value.object->cbegin();
18058 for (
std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
18060 o->write_characters(indent_string.c_str(), new_indent);
18061 o->write_character(
'\"');
18062 dump_escaped(i->first, ensure_ascii);
18063 o->write_characters(
"\": ", 3);
18064 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18065 o->write_characters(
",\n", 2);
18070 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
18071 o->write_characters(indent_string.c_str(), new_indent);
18072 o->write_character(
'\"');
18073 dump_escaped(i->first, ensure_ascii);
18074 o->write_characters(
"\": ", 3);
18075 dump(i->second,
true, ensure_ascii, indent_step, new_indent);
18077 o->write_character(
'\n');
18078 o->write_characters(indent_string.c_str(), current_indent);
18079 o->write_character(
'}');
18083 o->write_character(
'{');
18086 auto i = val.m_value.object->cbegin();
18087 for (
std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i)
18089 o->write_character(
'\"');
18090 dump_escaped(i->first, ensure_ascii);
18091 o->write_characters(
"\":", 2);
18092 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18093 o->write_character(
',');
18098 JSON_ASSERT(std::next(i) == val.m_value.object->cend());
18099 o->write_character(
'\"');
18100 dump_escaped(i->first, ensure_ascii);
18101 o->write_characters(
"\":", 2);
18102 dump(i->second,
false, ensure_ascii, indent_step, current_indent);
18104 o->write_character(
'}');
18110 case value_t::array:
18112 if (val.m_value.array->empty())
18114 o->write_characters(
"[]", 2);
18120 o->write_characters(
"[\n", 2);
18123 const auto new_indent = current_indent + indent_step;
18126 indent_string.resize(indent_string.size() * 2,
' ');
18130 for (
auto i = val.m_value.array->cbegin();
18131 i != val.m_value.array->cend() - 1; ++i)
18133 o->write_characters(indent_string.c_str(), new_indent);
18134 dump(*i,
true, ensure_ascii, indent_step, new_indent);
18135 o->write_characters(
",\n", 2);
18140 o->write_characters(indent_string.c_str(), new_indent);
18141 dump(val.m_value.array->back(),
true, ensure_ascii, indent_step, new_indent);
18143 o->write_character(
'\n');
18144 o->write_characters(indent_string.c_str(), current_indent);
18145 o->write_character(
']');
18149 o->write_character(
'[');
18152 for (
auto i = val.m_value.array->cbegin();
18153 i != val.m_value.array->cend() - 1; ++i)
18155 dump(*i,
false, ensure_ascii, indent_step, current_indent);
18156 o->write_character(
',');
18161 dump(val.m_value.array->back(),
false, ensure_ascii, indent_step, current_indent);
18163 o->write_character(
']');
18169 case value_t::string:
18171 o->write_character(
'\"');
18172 dump_escaped(*val.m_value.string, ensure_ascii);
18173 o->write_character(
'\"');
18177 case value_t::binary:
18181 o->write_characters(
"{\n", 2);
18184 const auto new_indent = current_indent + indent_step;
18187 indent_string.resize(indent_string.size() * 2,
' ');
18190 o->write_characters(indent_string.c_str(), new_indent);
18192 o->write_characters(
"\"bytes\": [", 10);
18194 if (!val.m_value.binary->empty())
18196 for (
auto i = val.m_value.binary->cbegin();
18197 i != val.m_value.binary->cend() - 1; ++i)
18200 o->write_characters(
", ", 2);
18202 dump_integer(val.m_value.binary->back());
18205 o->write_characters(
"],\n", 3);
18206 o->write_characters(indent_string.c_str(), new_indent);
18208 o->write_characters(
"\"subtype\": ", 11);
18209 if (val.m_value.binary->has_subtype())
18211 dump_integer(val.m_value.binary->subtype());
18215 o->write_characters(
"null", 4);
18217 o->write_character(
'\n');
18218 o->write_characters(indent_string.c_str(), current_indent);
18219 o->write_character(
'}');
18223 o->write_characters(
"{\"bytes\":[", 10);
18225 if (!val.m_value.binary->empty())
18227 for (
auto i = val.m_value.binary->cbegin();
18228 i != val.m_value.binary->cend() - 1; ++i)
18231 o->write_character(
',');
18233 dump_integer(val.m_value.binary->back());
18236 o->write_characters(
"],\"subtype\":", 12);
18237 if (val.m_value.binary->has_subtype())
18239 dump_integer(val.m_value.binary->subtype());
18240 o->write_character(
'}');
18244 o->write_characters(
"null}", 5);
18250 case value_t::boolean:
18252 if (val.m_value.boolean)
18254 o->write_characters(
"true", 4);
18258 o->write_characters(
"false", 5);
18263 case value_t::number_integer:
18265 dump_integer(val.m_value.number_integer);
18269 case value_t::number_unsigned:
18271 dump_integer(val.m_value.number_unsigned);
18275 case value_t::number_float:
18277 dump_float(val.m_value.number_float);
18281 case value_t::discarded:
18283 o->write_characters(
"<discarded>", 11);
18287 case value_t::null:
18289 o->write_characters(
"null", 4);
18313 void dump_escaped(
const string_t& s,
const bool ensure_ascii)
18315 std::uint32_t codepoint{};
18316 std::uint8_t state = UTF8_ACCEPT;
18325 const auto byte =
static_cast<std::uint8_t
>(s[i]);
18327 switch (decode(state, codepoint,
byte))
18335 string_buffer[bytes++] =
'\\';
18336 string_buffer[bytes++] =
'b';
18342 string_buffer[bytes++] =
'\\';
18343 string_buffer[bytes++] =
't';
18349 string_buffer[bytes++] =
'\\';
18350 string_buffer[bytes++] =
'n';
18356 string_buffer[bytes++] =
'\\';
18357 string_buffer[bytes++] =
'f';
18363 string_buffer[bytes++] =
'\\';
18364 string_buffer[bytes++] =
'r';
18370 string_buffer[bytes++] =
'\\';
18371 string_buffer[bytes++] =
'\"';
18377 string_buffer[bytes++] =
'\\';
18378 string_buffer[bytes++] =
'\\';
18386 if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F)))
18388 if (codepoint <= 0xFFFF)
18391 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 7,
"\\u%04x",
18392 static_cast<std::uint16_t
>(codepoint)));
18398 static_cast<void>((std::snprintf)(string_buffer.data() + bytes, 13,
"\\u%04x\\u%04x",
18399 static_cast<std::uint16_t
>(0xD7C0u + (codepoint >> 10u)),
18400 static_cast<std::uint16_t
>(0xDC00u + (codepoint & 0x3FFu))));
18408 string_buffer[bytes++] = s[i];
18417 if (string_buffer.size() - bytes < 13)
18419 o->write_characters(string_buffer.data(), bytes);
18424 bytes_after_last_accept = bytes;
18425 undumped_chars = 0;
18431 switch (error_handler)
18433 case error_handler_t::strict:
18435 JSON_THROW(type_error::create(316,
concat(
"invalid UTF-8 byte at index ", std::to_string(i),
": 0x", hex_bytes(
byte | 0)),
nullptr));
18438 case error_handler_t::ignore:
18439 case error_handler_t::replace:
18445 if (undumped_chars > 0)
18452 bytes = bytes_after_last_accept;
18454 if (error_handler == error_handler_t::replace)
18459 string_buffer[bytes++] =
'\\';
18460 string_buffer[bytes++] =
'u';
18461 string_buffer[bytes++] =
'f';
18462 string_buffer[bytes++] =
'f';
18463 string_buffer[bytes++] =
'f';
18464 string_buffer[bytes++] =
'd';
18476 if (string_buffer.size() - bytes < 13)
18478 o->write_characters(string_buffer.data(), bytes);
18482 bytes_after_last_accept = bytes;
18485 undumped_chars = 0;
18488 state = UTF8_ACCEPT;
18503 string_buffer[bytes++] = s[i];
18517 o->write_characters(string_buffer.data(), bytes);
18523 switch (error_handler)
18525 case error_handler_t::strict:
18527 JSON_THROW(type_error::create(316,
concat(
"incomplete UTF-8 string; last byte: 0x", hex_bytes(
static_cast<std::uint8_t
>(s.back() | 0))),
nullptr));
18530 case error_handler_t::ignore:
18533 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18537 case error_handler_t::replace:
18540 o->write_characters(string_buffer.data(), bytes_after_last_accept);
18544 o->write_characters(
"\\ufffd", 6);
18548 o->write_characters(
"\xEF\xBF\xBD", 3);
18568 inline unsigned int count_digits(number_unsigned_t x)
noexcept
18570 unsigned int n_digits = 1;
18579 return n_digits + 1;
18583 return n_digits + 2;
18587 return n_digits + 3;
18599 static std::string hex_bytes(std::uint8_t
byte)
18601 std::string result =
"FF";
18602 constexpr const char* nibble_to_hex =
"0123456789ABCDEF";
18603 result[0] = nibble_to_hex[
byte / 16];
18604 result[1] = nibble_to_hex[
byte % 16];
18609 template <typename NumberType, enable_if_t<std::is_signed<NumberType>::value,
int> = 0>
18610 bool is_negative_number(NumberType x)
18615 template < typename NumberType, enable_if_t <std::is_unsigned<NumberType>::value,
int > = 0 >
18616 bool is_negative_number(NumberType )
18631 std::is_integral<NumberType>::value ||
18632 std::is_same<NumberType, number_unsigned_t>::value ||
18633 std::is_same<NumberType, number_integer_t>::value ||
18634 std::is_same<NumberType, binary_char_t>::value,
18636 void dump_integer(NumberType x)
18638 static constexpr std::array<std::array<char, 2>, 100> digits_to_99
18641 {{
'0',
'0'}}, {{
'0',
'1'}}, {{
'0',
'2'}}, {{
'0',
'3'}}, {{
'0',
'4'}}, {{
'0',
'5'}}, {{
'0',
'6'}}, {{
'0',
'7'}}, {{
'0',
'8'}}, {{
'0',
'9'}},
18642 {{
'1',
'0'}}, {{
'1',
'1'}}, {{
'1',
'2'}}, {{
'1',
'3'}}, {{
'1',
'4'}}, {{
'1',
'5'}}, {{
'1',
'6'}}, {{
'1',
'7'}}, {{
'1',
'8'}}, {{
'1',
'9'}},
18643 {{
'2',
'0'}}, {{
'2',
'1'}}, {{
'2',
'2'}}, {{
'2',
'3'}}, {{
'2',
'4'}}, {{
'2',
'5'}}, {{
'2',
'6'}}, {{
'2',
'7'}}, {{
'2',
'8'}}, {{
'2',
'9'}},
18644 {{
'3',
'0'}}, {{
'3',
'1'}}, {{
'3',
'2'}}, {{
'3',
'3'}}, {{
'3',
'4'}}, {{
'3',
'5'}}, {{
'3',
'6'}}, {{
'3',
'7'}}, {{
'3',
'8'}}, {{
'3',
'9'}},
18645 {{
'4',
'0'}}, {{
'4',
'1'}}, {{
'4',
'2'}}, {{
'4',
'3'}}, {{
'4',
'4'}}, {{
'4',
'5'}}, {{
'4',
'6'}}, {{
'4',
'7'}}, {{
'4',
'8'}}, {{
'4',
'9'}},
18646 {{
'5',
'0'}}, {{
'5',
'1'}}, {{
'5',
'2'}}, {{
'5',
'3'}}, {{
'5',
'4'}}, {{
'5',
'5'}}, {{
'5',
'6'}}, {{
'5',
'7'}}, {{
'5',
'8'}}, {{
'5',
'9'}},
18647 {{
'6',
'0'}}, {{
'6',
'1'}}, {{
'6',
'2'}}, {{
'6',
'3'}}, {{
'6',
'4'}}, {{
'6',
'5'}}, {{
'6',
'6'}}, {{
'6',
'7'}}, {{
'6',
'8'}}, {{
'6',
'9'}},
18648 {{
'7',
'0'}}, {{
'7',
'1'}}, {{
'7',
'2'}}, {{
'7',
'3'}}, {{
'7',
'4'}}, {{
'7',
'5'}}, {{
'7',
'6'}}, {{
'7',
'7'}}, {{
'7',
'8'}}, {{
'7',
'9'}},
18649 {{
'8',
'0'}}, {{
'8',
'1'}}, {{
'8',
'2'}}, {{
'8',
'3'}}, {{
'8',
'4'}}, {{
'8',
'5'}}, {{
'8',
'6'}}, {{
'8',
'7'}}, {{
'8',
'8'}}, {{
'8',
'9'}},
18650 {{
'9',
'0'}}, {{
'9',
'1'}}, {{
'9',
'2'}}, {{
'9',
'3'}}, {{
'9',
'4'}}, {{
'9',
'5'}}, {{
'9',
'6'}}, {{
'9',
'7'}}, {{
'9',
'8'}}, {{
'9',
'9'}},
18657 o->write_character(
'0');
18662 auto buffer_ptr = number_buffer.begin();
18664 number_unsigned_t abs_value;
18666 unsigned int n_chars{};
18668 if (is_negative_number(x))
18671 abs_value = remove_sign(
static_cast<number_integer_t
>(x));
18674 n_chars = 1 + count_digits(abs_value);
18678 abs_value =
static_cast<number_unsigned_t
>(x);
18679 n_chars = count_digits(abs_value);
18687 buffer_ptr += n_chars;
18691 while (abs_value >= 100)
18693 const auto digits_index =
static_cast<unsigned>((abs_value % 100));
18695 *(--buffer_ptr) = digits_to_99[digits_index][1];
18696 *(--buffer_ptr) = digits_to_99[digits_index][0];
18699 if (abs_value >= 10)
18701 const auto digits_index =
static_cast<unsigned>(abs_value);
18702 *(--buffer_ptr) = digits_to_99[digits_index][1];
18703 *(--buffer_ptr) = digits_to_99[digits_index][0];
18707 *(--buffer_ptr) =
static_cast<char>(
'0' + abs_value);
18710 o->write_characters(number_buffer.data(), n_chars);
18721 void dump_float(number_float_t x)
18724 if (!std::isfinite(x))
18726 o->write_characters(
"null", 4);
18735 static constexpr bool is_ieee_single_or_double
18736 = (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 24 && std::numeric_limits<number_float_t>::max_exponent == 128) ||
18737 (std::numeric_limits<number_float_t>::is_iec559 && std::numeric_limits<number_float_t>::digits == 53 && std::numeric_limits<number_float_t>::max_exponent == 1024);
18739 dump_float(x, std::integral_constant<bool, is_ieee_single_or_double>());
18742 void dump_float(number_float_t x, std::true_type )
18744 auto* begin = number_buffer.data();
18745 auto* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x);
18747 o->write_characters(begin,
static_cast<size_t>(end - begin));
18750 void dump_float(number_float_t x, std::false_type )
18753 static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
18757 std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(),
"%.*g", d, x);
18765 if (thousands_sep !=
'\0')
18768 const auto end = std::remove(number_buffer.begin(), number_buffer.begin() + len, thousands_sep);
18769 std::fill(end, number_buffer.end(),
'\0');
18770 JSON_ASSERT((end - number_buffer.begin()) <= len);
18771 len = (end - number_buffer.begin());
18775 if (decimal_point !=
'\0' && decimal_point !=
'.')
18778 const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point);
18779 if (dec_pos != number_buffer.end())
18785 o->write_characters(number_buffer.data(),
static_cast<std::size_t>(len));
18788 const bool value_is_int_like =
18789 std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
18792 return c ==
'.' || c ==
'e';
18795 if (value_is_int_like)
18797 o->write_characters(
".0", 2);
18822 static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep,
const std::uint8_t
byte)
noexcept
18824 static const std::array<std::uint8_t, 400> utf8d =
18827 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18828 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18829 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18830 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
18831 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
18832 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
18833 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
18834 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3,
18835 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
18836 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1,
18837 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1,
18838 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
18839 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1,
18840 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
18845 const std::uint8_t type = utf8d[byte];
18847 codep = (state != UTF8_ACCEPT)
18848 ? (
byte & 0x3fu) | (codep << 6u)
18849 : (0xFFu >> type) & (byte);
18851 const std::size_t index = 256u +
static_cast<size_t>(state) * 16u +
static_cast<size_t>(type);
18853 state = utf8d[index];
18862 number_unsigned_t remove_sign(number_unsigned_t x)
18877 inline number_unsigned_t remove_sign(number_integer_t x)
noexcept
18879 JSON_ASSERT(x < 0 && x < (std::numeric_limits<number_integer_t>::max)());
18880 return static_cast<number_unsigned_t
>(-(x + 1)) + 1;
18885 output_adapter_t<char> o =
nullptr;
18888 std::array<char, 64> number_buffer{{}};
18891 const std::lconv* loc =
nullptr;
18893 const char thousands_sep =
'\0';
18895 const char decimal_point =
'\0';
18898 std::array<char, 512> string_buffer{{}};
18901 const char indent_char;
18903 string_t indent_string;
18927#include <functional>
18928#include <initializer_list>
18931#include <stdexcept>
18932#include <type_traits>
18945template <
class Key,
class T,
class IgnoredLess = std::less<Key>,
18946 class Allocator = std::allocator<std::pair<const Key, T>>>
18947 struct ordered_map : std::vector<std::pair<const Key, T>, Allocator>
18951 using Container = std::vector<std::pair<const Key, T>, Allocator>;
18956#ifdef JSON_HAS_CPP_14
18966 template <
class It>
18969 ordered_map(std::initializer_list<value_type> init,
const Allocator& alloc = Allocator() )
18974 for (
auto it = this->begin(); it != this->end(); ++it)
18976 if (m_compare(it->first, key))
18978 return {it,
false};
18981 Container::emplace_back(key, std::forward<T>(t));
18982 return {std::prev(this->end()),
true};
18987 std::pair<iterator, bool>
emplace(KeyType && key, T && t)
18989 for (
auto it = this->begin(); it != this->end(); ++it)
18991 if (m_compare(it->first, key))
18993 return {it,
false};
18996 Container::emplace_back(std::forward<KeyType>(key), std::forward<T>(t));
18997 return {std::prev(this->end()),
true};
19002 return emplace(key, T{}).first->second;
19009 return emplace(std::forward<KeyType>(key), T{}).first->second;
19021 return at(std::forward<KeyType>(key));
19026 for (
auto it = this->begin(); it != this->end(); ++it)
19028 if (m_compare(it->first, key))
19034 JSON_THROW(std::out_of_range(
"key not found"));
19041 for (
auto it = this->begin(); it != this->end(); ++it)
19043 if (m_compare(it->first, key))
19049 JSON_THROW(std::out_of_range(
"key not found"));
19054 for (
auto it = this->begin(); it != this->end(); ++it)
19056 if (m_compare(it->first, key))
19062 JSON_THROW(std::out_of_range(
"key not found"));
19067 const T &
at(KeyType && key)
const
19069 for (
auto it = this->begin(); it != this->end(); ++it)
19071 if (m_compare(it->first, key))
19077 JSON_THROW(std::out_of_range(
"key not found"));
19082 for (
auto it = this->begin(); it != this->end(); ++it)
19084 if (m_compare(it->first, key))
19087 for (
auto next = it; ++next != this->end(); ++it)
19092 Container::pop_back();
19103 for (
auto it = this->begin(); it != this->end(); ++it)
19105 if (m_compare(it->first, key))
19108 for (
auto next = it; ++next != this->end(); ++it)
19113 Container::pop_back();
19122 return erase(pos, std::next(pos));
19132 const auto elements_affected = std::distance(first, last);
19133 const auto offset = std::distance(Container::begin(), first);
19155 for (
auto it = first; std::next(it, elements_affected) != Container::end(); ++it)
19158 new (&*it)
value_type{std::move(*std::next(it, elements_affected))};
19166 Container::resize(this->size() -
static_cast<size_type>(elements_affected));
19175 return Container::begin() + offset;
19180 for (
auto it = this->begin(); it != this->end(); ++it)
19182 if (m_compare(it->first, key))
19194 for (
auto it = this->begin(); it != this->end(); ++it)
19196 if (m_compare(it->first, key))
19206 for (
auto it = this->begin(); it != this->end(); ++it)
19208 if (m_compare(it->first, key))
19213 return Container::end();
19220 for (
auto it = this->begin(); it != this->end(); ++it)
19222 if (m_compare(it->first, key))
19227 return Container::end();
19232 for (
auto it = this->begin(); it != this->end(); ++it)
19234 if (m_compare(it->first, key))
19239 return Container::end();
19244 return emplace(value.first, std::move(value.second));
19249 for (
auto it = this->begin(); it != this->end(); ++it)
19251 if (m_compare(it->first, value.first))
19253 return {it,
false};
19256 Container::push_back(value);
19257 return {--this->end(),
true};
19260 template<
typename InputIt>
19261 using require_input_iter =
typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIt>::iterator_category,
19262 std::input_iterator_tag>::value>::type;
19264 template<
typename InputIt,
typename = require_input_iter<InputIt>>
19267 for (
auto it = first; it != last; ++it)
19280#if defined(JSON_HAS_CPP_17)
19282 #include <string_view>
19312 :
public ::nlohmann::detail::json_base_class<CustomBaseClass>
19318 friend class ::nlohmann::json_pointer;
19322 template<
typename BasicJsonType,
typename InputType>
19323 friend class ::nlohmann::detail::parser;
19324 friend ::nlohmann::detail::serializer<basic_json>;
19325 template<
typename BasicJsonType>
19326 friend class ::nlohmann::detail::iter_impl;
19327 template<
typename BasicJsonType,
typename CharType>
19328 friend class ::nlohmann::detail::binary_writer;
19329 template<
typename BasicJsonType,
typename InputType,
typename SAX>
19330 friend class ::nlohmann::detail::binary_reader;
19331 template<
typename BasicJsonType>
19332 friend class ::nlohmann::detail::json_sax_dom_parser;
19333 template<
typename BasicJsonType>
19334 friend class ::nlohmann::detail::json_sax_dom_callback_parser;
19335 friend class ::nlohmann::detail::exception;
19343 using lexer = ::nlohmann::detail::lexer_base<basic_json>;
19345 template<
typename InputAdapterType>
19346 static ::nlohmann::detail::parser<basic_json, InputAdapterType>
parser(
19347 InputAdapterType adapter,
19349 const bool allow_exceptions =
true,
19350 const bool ignore_comments =
false
19353 return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
19354 std::move(cb), allow_exceptions, ignore_comments);
19359 template<
typename BasicJsonType>
19361 template<
typename BasicJsonType>
19363 template<
typename Iterator>
19367 template<
typename CharType>
19370 template<
typename InputType>
19372 template<
typename CharType>
using binary_writer = ::nlohmann::detail::binary_writer<basic_json, CharType>;
19375 using serializer = ::nlohmann::detail::serializer<basic_json>;
19381 template<
typename T,
typename SFINAE>
19438 using pointer =
typename std::allocator_traits<allocator_type>::pointer;
19440 using const_pointer =
typename std::allocator_traits<allocator_type>::const_pointer;
19468 result[
"copyright"] =
"(C) 2013-2022 Niels Lohmann";
19469 result[
"name"] =
"JSON for Modern C++";
19470 result[
"url"] =
"https://github.com/nlohmann/json";
19471 result[
"version"][
"string"] =
19480 result[
"platform"] =
"win32";
19481#elif defined __linux__
19482 result[
"platform"] =
"linux";
19483#elif defined __APPLE__
19484 result[
"platform"] =
"apple";
19485#elif defined __unix__
19486 result[
"platform"] =
"unix";
19488 result[
"platform"] =
"unknown";
19491#if defined(__ICC) || defined(__INTEL_COMPILER)
19492 result[
"compiler"] = {{
"family",
"icc"}, {
"version", __INTEL_COMPILER}};
19493#elif defined(__clang__)
19494 result[
"compiler"] = {{
"family",
"clang"}, {
"version", __clang_version__}};
19495#elif defined(__GNUC__) || defined(__GNUG__)
19496 result[
"compiler"] = {{
"family",
"gcc"}, {
"version",
detail::concat(
19502#elif defined(__HP_cc) || defined(__HP_aCC)
19503 result[
"compiler"] =
"hp"
19504#elif defined(__IBMCPP__)
19505 result[
"compiler"] = {{
"family",
"ilecpp"}, {
"version", __IBMCPP__}};
19506#elif defined(_MSC_VER)
19507 result[
"compiler"] = {{
"family",
"msvc"}, {
"version", _MSC_VER}};
19508#elif defined(__PGI)
19509 result[
"compiler"] = {{
"family",
"pgcpp"}, {
"version", __PGI}};
19510#elif defined(__SUNPRO_CC)
19511 result[
"compiler"] = {{
"family",
"sunpro"}, {
"version", __SUNPRO_CC}};
19513 result[
"compiler"] = {{
"family",
"unknown"}, {
"version",
"unknown"}};
19517#if defined(_MSVC_LANG)
19518 result[
"compiler"][
"c++"] = std::to_string(_MSVC_LANG);
19519#elif defined(__cplusplus)
19520 result[
"compiler"][
"c++"] = std::to_string(
__cplusplus);
19522 result[
"compiler"][
"c++"] =
"unknown";
19541#if defined(JSON_HAS_CPP_14)
19544 using default_object_comparator_t = std::less<>;
19554 AllocatorType<std::pair<
const StringType,
19559 using array_t = ArrayType<basic_json, AllocatorType<basic_json>>;
19583 using binary_t = nlohmann::byte_container_with_subtype<BinaryType>;
19594 template<
typename T,
typename... Args>
19598 AllocatorType<T> alloc;
19599 using AllocatorTraits = std::allocator_traits<AllocatorType<T>>;
19601 auto deleter = [&](T * obj)
19603 AllocatorTraits::deallocate(alloc, obj, 1);
19605 std::unique_ptr<T,
decltype(deleter)> obj(AllocatorTraits::allocate(alloc, 1), deleter);
19606 AllocatorTraits::construct(alloc, obj.get(), std::forward<Args>(args)...);
19608 return obj.release();
19654 number_integer_t number_integer;
19656 number_unsigned_t number_unsigned;
19658 number_float_t number_float;
19675 case value_t::object:
19677 object = create<object_t>();
19681 case value_t::array:
19683 array = create<array_t>();
19687 case value_t::string:
19689 string = create<string_t>(
"");
19693 case value_t::binary:
19695 binary = create<binary_t>();
19699 case value_t::boolean:
19701 boolean =
static_cast<boolean_t>(
false);
19705 case value_t::number_integer:
19711 case value_t::number_unsigned:
19717 case value_t::number_float:
19723 case value_t::null:
19729 case value_t::discarded:
19735 JSON_THROW(other_error::create(500,
"961c151d2e87f2686a955a9be24d316f1362bf21 3.11.2",
nullptr));
19774 if (t == value_t::array || t == value_t::object)
19777 std::vector<basic_json> stack;
19780 if (t == value_t::array)
19782 stack.reserve(array->size());
19783 std::move(array->begin(), array->end(), std::back_inserter(stack));
19787 stack.reserve(object->size());
19788 for (
auto&& it : *object)
19790 stack.push_back(std::move(it.second));
19794 while (!stack.empty())
19797 basic_json current_item(std::move(stack.back()));
19802 if (current_item.is_array())
19804 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
19806 current_item.m_value.array->clear();
19808 else if (current_item.is_object())
19810 for (
auto&& it : *current_item.m_value.object)
19812 stack.push_back(std::move(it.second));
19815 current_item.m_value.object->clear();
19825 case value_t::object:
19827 AllocatorType<object_t> alloc;
19828 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
object);
19829 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
object, 1);
19833 case value_t::array:
19835 AllocatorType<array_t> alloc;
19836 std::allocator_traits<
decltype(alloc)>::destroy(alloc, array);
19837 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, array, 1);
19841 case value_t::string:
19843 AllocatorType<string_t> alloc;
19844 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
string);
19845 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
string, 1);
19849 case value_t::binary:
19851 AllocatorType<binary_t> alloc;
19852 std::allocator_traits<
decltype(alloc)>::destroy(alloc, binary);
19853 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, binary, 1);
19857 case value_t::null:
19858 case value_t::boolean:
19859 case value_t::number_integer:
19860 case value_t::number_unsigned:
19861 case value_t::number_float:
19862 case value_t::discarded:
19892 JSON_ASSERT(m_type != value_t::object || m_value.object !=
nullptr);
19893 JSON_ASSERT(m_type != value_t::array || m_value.array !=
nullptr);
19894 JSON_ASSERT(m_type != value_t::string || m_value.string !=
nullptr);
19895 JSON_ASSERT(m_type != value_t::binary || m_value.binary !=
nullptr);
19897#if JSON_DIAGNOSTICS
19901 JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [
this](
const basic_json & j)
19903 return j.m_parent ==
this;
19908 static_cast<void>(check_parents);
19913#if JSON_DIAGNOSTICS
19916 case value_t::array:
19918 for (
auto& element : *m_value.array)
19920 element.m_parent =
this;
19925 case value_t::object:
19927 for (
auto& element : *m_value.object)
19929 element.second.m_parent =
this;
19934 case value_t::null:
19935 case value_t::string:
19936 case value_t::boolean:
19937 case value_t::number_integer:
19938 case value_t::number_unsigned:
19939 case value_t::number_float:
19940 case value_t::binary:
19941 case value_t::discarded:
19950#if JSON_DIAGNOSTICS
19951 for (
typename iterator::difference_type i = 0; i < count_set_parents; ++i)
19953 (it + i)->m_parent =
this;
19956 static_cast<void>(count_set_parents);
19963#if JSON_DIAGNOSTICS
19964 if (old_capacity !=
static_cast<std::size_t>(-1))
19978#ifdef JSON_HEDLEY_MSVC_VERSION
19979#pragma warning(push )
19980#pragma warning(disable : 4127)
19987#ifdef JSON_HEDLEY_MSVC_VERSION
19988#pragma warning( pop )
19993 static_cast<void>(j);
19994 static_cast<void>(old_capacity);
20024 : m_type(v), m_value(v)
20026 assert_invariant();
20034 assert_invariant();
20039 template <
typename CompatibleType,
20044 JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
20045 std::forward<CompatibleType>(val))))
20047 JSONSerializer<U>::to_json(*
this, std::forward<CompatibleType>(val));
20049 assert_invariant();
20054 template <
typename BasicJsonType,
20059 using other_boolean_t =
typename BasicJsonType::boolean_t;
20060 using other_number_float_t =
typename BasicJsonType::number_float_t;
20061 using other_number_integer_t =
typename BasicJsonType::number_integer_t;
20062 using other_number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
20063 using other_string_t =
typename BasicJsonType::string_t;
20064 using other_object_t =
typename BasicJsonType::object_t;
20065 using other_array_t =
typename BasicJsonType::array_t;
20066 using other_binary_t =
typename BasicJsonType::binary_t;
20068 switch (val.type())
20070 case value_t::boolean:
20071 JSONSerializer<other_boolean_t>::to_json(*
this, val.template get<other_boolean_t>());
20073 case value_t::number_float:
20074 JSONSerializer<other_number_float_t>::to_json(*
this, val.template get<other_number_float_t>());
20076 case value_t::number_integer:
20077 JSONSerializer<other_number_integer_t>::to_json(*
this, val.template get<other_number_integer_t>());
20079 case value_t::number_unsigned:
20080 JSONSerializer<other_number_unsigned_t>::to_json(*
this, val.template get<other_number_unsigned_t>());
20082 case value_t::string:
20083 JSONSerializer<other_string_t>::to_json(*
this, val.template get_ref<const other_string_t&>());
20085 case value_t::object:
20086 JSONSerializer<other_object_t>::to_json(*
this, val.template get_ref<const other_object_t&>());
20088 case value_t::array:
20089 JSONSerializer<other_array_t>::to_json(*
this, val.template get_ref<const other_array_t&>());
20091 case value_t::binary:
20092 JSONSerializer<other_binary_t>::to_json(*
this, val.template get_ref<const other_binary_t&>());
20094 case value_t::null:
20097 case value_t::discarded:
20098 m_type = value_t::discarded;
20105 assert_invariant();
20111 bool type_deduction =
true,
20112 value_t manual_type = value_t::array)
20116 bool is_an_object = std::all_of(init.begin(), init.end(),
20119 return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string();
20123 if (!type_deduction)
20126 if (manual_type == value_t::array)
20128 is_an_object =
false;
20134 JSON_THROW(type_error::create(301,
"cannot create object from initializer list",
nullptr));
20141 m_type = value_t::object;
20142 m_value = value_t::object;
20144 for (
auto& element_ref : init)
20146 auto element = element_ref.moved_or_copied();
20147 m_value.object->emplace(
20148 std::move(*((*element.m_value.array)[0].m_value.string)),
20149 std::move((*element.m_value.array)[1]));
20155 m_type = value_t::array;
20156 m_value.array = create<array_t>(init.begin(), init.end());
20160 assert_invariant();
20169 res.m_type = value_t::binary;
20170 res.m_value = init;
20177 static basic_json binary(
const typename binary_t::container_type& init,
typename binary_t::subtype_type subtype)
20180 res.m_type = value_t::binary;
20181 res.m_value =
binary_t(init, subtype);
20191 res.m_type = value_t::binary;
20192 res.m_value = std::move(init);
20199 static basic_json binary(
typename binary_t::container_type&& init,
typename binary_t::subtype_type subtype)
20202 res.m_type = value_t::binary;
20203 res.m_value =
binary_t(std::move(init), subtype);
20212 return basic_json(init,
false, value_t::array);
20220 return basic_json(init,
false, value_t::object);
20228 m_value.array = create<array_t>(cnt, val);
20230 assert_invariant();
20235 template <
class InputIT,
typename std::enable_if <
20236 std::is_same<InputIT, typename basic_json_t::iterator>::value ||
20237 std::is_same<InputIT, typename basic_json_t::const_iterator>::value,
int >::type = 0 >
20246 JSON_THROW(invalid_iterator::create(201,
"iterators are not compatible",
nullptr));
20250 m_type = first.m_object->m_type;
20255 case value_t::boolean:
20256 case value_t::number_float:
20257 case value_t::number_integer:
20258 case value_t::number_unsigned:
20259 case value_t::string:
20262 || !last.m_it.primitive_iterator.is_end()))
20264 JSON_THROW(invalid_iterator::create(204,
"iterators out of range", first.m_object));
20269 case value_t::null:
20270 case value_t::object:
20271 case value_t::array:
20272 case value_t::binary:
20273 case value_t::discarded:
20280 case value_t::number_integer:
20282 m_value.number_integer = first.m_object->m_value.number_integer;
20286 case value_t::number_unsigned:
20288 m_value.number_unsigned = first.m_object->m_value.number_unsigned;
20292 case value_t::number_float:
20294 m_value.number_float = first.m_object->m_value.number_float;
20298 case value_t::boolean:
20300 m_value.boolean = first.m_object->m_value.boolean;
20304 case value_t::string:
20306 m_value = *first.m_object->m_value.string;
20310 case value_t::object:
20312 m_value.object = create<object_t>(first.m_it.object_iterator,
20313 last.m_it.object_iterator);
20317 case value_t::array:
20319 m_value.array = create<array_t>(first.m_it.array_iterator,
20320 last.m_it.array_iterator);
20324 case value_t::binary:
20326 m_value = *first.m_object->m_value.binary;
20330 case value_t::null:
20331 case value_t::discarded:
20333 JSON_THROW(invalid_iterator::create(206,
detail::concat(
"cannot construct with iterators from ", first.m_object->type_name()), first.m_object));
20337 assert_invariant();
20345 template<
typename JsonRef,
20347 std::is_same<typename JsonRef::value_type, basic_json>>::value,
int> = 0 >
20354 m_type(other.m_type)
20357 other.assert_invariant();
20361 case value_t::object:
20363 m_value = *other.m_value.object;
20367 case value_t::array:
20369 m_value = *other.m_value.array;
20373 case value_t::string:
20375 m_value = *other.m_value.string;
20379 case value_t::boolean:
20381 m_value = other.m_value.boolean;
20385 case value_t::number_integer:
20387 m_value = other.m_value.number_integer;
20391 case value_t::number_unsigned:
20393 m_value = other.m_value.number_unsigned;
20397 case value_t::number_float:
20399 m_value = other.m_value.number_float;
20403 case value_t::binary:
20405 m_value = *other.m_value.binary;
20409 case value_t::null:
20410 case value_t::discarded:
20416 assert_invariant();
20423 m_type(std::move(other.m_type)),
20424 m_value(std::move(other.m_value))
20427 other.assert_invariant(
false);
20430 other.m_type = value_t::null;
20431 other.m_value = {};
20434 assert_invariant();
20440 std::is_nothrow_move_constructible<value_t>::value&&
20441 std::is_nothrow_move_assignable<value_t>::value&&
20442 std::is_nothrow_move_constructible<json_value>::value&&
20443 std::is_nothrow_move_assignable<json_value>::value&&
20444 std::is_nothrow_move_assignable<json_base_class_t>::value
20451 swap(m_type, other.m_type);
20452 swap(m_value, other.m_value);
20453 json_base_class_t::operator=(std::move(other));
20456 assert_invariant();
20464 assert_invariant(
false);
20465 m_value.destroy(m_type);
20482 const char indent_char =
' ',
20483 const bool ensure_ascii =
false,
20491 s.dump(*
this,
true, ensure_ascii,
static_cast<unsigned int>(indent));
20495 s.dump(*
this,
false, ensure_ascii, 0);
20512 return is_null() || is_string() || is_boolean() || is_number() || is_binary();
20519 return is_array() || is_object();
20526 return m_type == value_t::null;
20533 return m_type == value_t::boolean;
20540 return is_number_integer() || is_number_float();
20547 return m_type == value_t::number_integer || m_type == value_t::number_unsigned;
20554 return m_type == value_t::number_unsigned;
20561 return m_type == value_t::number_float;
20568 return m_type == value_t::object;
20575 return m_type == value_t::array;
20582 return m_type == value_t::string;
20589 return m_type == value_t::binary;
20596 return m_type == value_t::discarded;
20618 return m_value.boolean;
20627 return is_object() ? m_value.object :
nullptr;
20633 return is_object() ? m_value.object :
nullptr;
20639 return is_array() ? m_value.array :
nullptr;
20645 return is_array() ? m_value.array :
nullptr;
20651 return is_string() ? m_value.string :
nullptr;
20657 return is_string() ? m_value.string :
nullptr;
20663 return is_boolean() ? &m_value.boolean :
nullptr;
20669 return is_boolean() ? &m_value.boolean :
nullptr;
20675 return is_number_integer() ? &m_value.number_integer :
nullptr;
20681 return is_number_integer() ? &m_value.number_integer :
nullptr;
20687 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
20693 return is_number_unsigned() ? &m_value.number_unsigned :
nullptr;
20699 return is_number_float() ? &m_value.number_float :
nullptr;
20705 return is_number_float() ? &m_value.number_float :
nullptr;
20711 return is_binary() ? m_value.binary :
nullptr;
20717 return is_binary() ? m_value.binary :
nullptr;
20731 template<
typename ReferenceType,
typename ThisType>
20735 auto* ptr = obj.template get_ptr<typename std::add_pointer<ReferenceType>::type>();
20742 JSON_THROW(type_error::create(303,
detail::concat(
"incompatible ReferenceType for get_ref, actual type is ", obj.type_name()), &obj));
20752 template<
typename PointerType,
typename std::enable_if<
20753 std::is_pointer<PointerType>::value,
int>::type = 0>
20757 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20762 template <
typename PointerType,
typename std::enable_if <
20763 std::is_pointer<PointerType>::value&&
20764 std::is_const<typename std::remove_pointer<PointerType>::type>::value,
int >::type = 0 >
20768 return get_impl_ptr(
static_cast<PointerType
>(
nullptr));
20810 template <
typename ValueType,
20816 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
20818 auto ret = ValueType();
20819 JSONSerializer<ValueType>::from_json(*
this, ret);
20853 template <
typename ValueType,
20858 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
20860 return JSONSerializer<ValueType>::from_json(*
this);
20878 template <
typename BasicJsonType,
20901 template<
typename BasicJsonType,
20903 std::is_same<BasicJsonType, basic_json_t>::value,
20914 template<
typename PointerType,
20916 std::is_pointer<PointerType>::value,
20919 ->
decltype(std::declval<const basic_json_t&>().template get_ptr<PointerType>())
20922 return get_ptr<PointerType>();
20949 template <
typename ValueTypeCV,
typename ValueType = detail::uncvref_t<ValueTypeCV>>
20950#if defined(JSON_HAS_CPP_14)
20954 noexcept(
std::declval<const
basic_json_t&>().template get_impl<ValueType>(
detail::priority_tag<4> {})))
20960 static_assert(!std::is_reference<ValueTypeCV>::value,
20961 "get() cannot be used with reference types, you might want to use get_ref()");
20992 template<
typename PointerType,
typename std::enable_if<
20993 std::is_pointer<PointerType>::value,
int>::type = 0>
20997 return get_ptr<PointerType>();
21002 template <
typename ValueType,
21007 ValueType &
get_to(ValueType& v)
const noexcept(
noexcept(
21008 JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21010 JSONSerializer<ValueType>::from_json(*
this, v);
21016 template<
typename ValueType,
21028 typename Array = T (&)[N],
21032 noexcept(
noexcept(JSONSerializer<Array>::from_json(
21033 std::declval<const basic_json_t&>(), v)))
21035 JSONSerializer<Array>::from_json(*
this, v);
21041 template<
typename ReferenceType,
typename std::enable_if<
21042 std::is_reference<ReferenceType>::value,
int>::type = 0>
21046 return get_ref_impl<ReferenceType>(*
this);
21051 template <
typename ReferenceType,
typename std::enable_if <
21052 std::is_reference<ReferenceType>::value&&
21053 std::is_const<typename std::remove_reference<ReferenceType>::type>::value,
int >::type = 0 >
21057 return get_ref_impl<ReferenceType>(*
this);
21089 template <
typename ValueType,
typename std::enable_if <
21097#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
21100#if defined(JSON_HAS_CPP_17)
21104 >::value,
int >::type = 0 >
21108 return get<ValueType>();
21120 return *get_ptr<binary_t*>();
21132 return *get_ptr<const binary_t*>();
21155 return set_parent(m_value.array->at(idx));
21160 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
21178 return m_value.array->at(idx);
21183 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
21202 auto it = m_value.object->find(key);
21203 if (it == m_value.object->end())
21207 return set_parent(it->second);
21222 auto it = m_value.object->find(std::forward<KeyType>(key));
21223 if (it == m_value.object->end())
21227 return set_parent(it->second);
21240 auto it = m_value.object->find(key);
21241 if (it == m_value.object->end())
21260 auto it = m_value.object->find(std::forward<KeyType>(key));
21261 if (it == m_value.object->end())
21275 m_type = value_t::array;
21276 m_value.
array = create<array_t>();
21277 assert_invariant();
21284 if (idx >= m_value.array->size())
21286#if JSON_DIAGNOSTICS
21288 const auto old_size = m_value.array->size();
21289 const auto old_capacity = m_value.array->capacity();
21291 m_value.array->resize(idx + 1);
21293#if JSON_DIAGNOSTICS
21302 set_parents(begin() +
static_cast<typename iterator::difference_type
>(old_size),
static_cast<typename iterator::difference_type
>(idx + 1 - old_size));
21305 assert_invariant();
21308 return m_value.array->operator[](idx);
21311 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
21321 return m_value.
array->operator[](idx);
21324 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a numeric argument with ", type_name()),
this));
21334 m_type = value_t::object;
21335 m_value.
object = create<object_t>();
21336 assert_invariant();
21342 auto result = m_value.object->emplace(std::move(key),
nullptr);
21343 return set_parent(result.first->second);
21346 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21356 auto it = m_value.
object->find(key);
21361 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21366 template<
typename T>
21369 return operator[](
typename object_t::key_type(key));
21372 template<
typename T>
21375 return operator[](
typename object_t::key_type(key));
21387 m_type = value_t::object;
21388 m_value.
object = create<object_t>();
21389 assert_invariant();
21395 auto result = m_value.object->emplace(std::forward<KeyType>(key),
nullptr);
21396 return set_parent(result.first->second);
21399 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21411 auto it = m_value.
object->find(std::forward<KeyType>(key));
21416 JSON_THROW(type_error::create(305,
detail::concat(
"cannot use operator[] with a string argument with ", type_name()),
this));
21420 template<
typename KeyType>
21424 template<
typename ValueType>
21427 string_t,
typename std::decay<ValueType>::type >;
21435 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21436 ValueType
value(
const typename object_t::key_type& key,
const ValueType& default_value)
const
21442 const auto it = find(key);
21445 return it->template get<ValueType>();
21448 return default_value;
21456 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21460 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21461 ReturnType
value(
const typename object_t::key_type& key, ValueType && default_value)
const
21467 const auto it = find(key);
21470 return it->template get<ReturnType>();
21473 return std::forward<ValueType>(default_value);
21484 && is_comparable_with_object_key<KeyType>::value
21486 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21487 ValueType
value(KeyType && key,
const ValueType& default_value)
const
21493 const auto it = find(std::forward<KeyType>(key));
21496 return it->template get<ValueType>();
21499 return default_value;
21507 template < class ValueType, class KeyType, class ReturnType = typename value_return_type<ValueType>::type,
21511 && is_comparable_with_object_key<KeyType>::value
21513 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21514 ReturnType
value(KeyType && key, ValueType && default_value)
const
21520 const auto it = find(std::forward<KeyType>(key));
21523 return it->template get<ReturnType>();
21526 return std::forward<ValueType>(default_value);
21536 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21545 return ptr.
get_checked(
this).template get<ValueType>();
21549 return default_value;
21558 template < class ValueType, class ReturnType = typename value_return_type<ValueType>::type,
21561 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21570 return ptr.
get_checked(
this).template get<ReturnType>();
21574 return std::forward<ValueType>(default_value);
21584 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21586 ValueType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, const ValueType& default_value)
const
21588 return value(ptr.convert(), default_value);
21591 template < class ValueType, class BasicJsonType, class ReturnType = typename value_return_type<ValueType>::type,
21595 && !std::is_same<value_t, detail::uncvref_t<ValueType>>::value,
int > = 0 >
21597 ReturnType value(const ::nlohmann::
json_pointer<BasicJsonType>& ptr, ValueType && default_value)
const
21599 return value(ptr.convert(), std::forward<ValueType>(default_value));
21637 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21638 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21644 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
21647 IteratorType result = end();
21651 case value_t::boolean:
21652 case value_t::number_float:
21653 case value_t::number_integer:
21654 case value_t::number_unsigned:
21655 case value_t::string:
21656 case value_t::binary:
21660 JSON_THROW(invalid_iterator::create(205,
"iterator out of range",
this));
21665 AllocatorType<string_t> alloc;
21666 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.string);
21667 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21668 m_value.string =
nullptr;
21670 else if (is_binary())
21672 AllocatorType<binary_t> alloc;
21673 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.binary);
21674 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21675 m_value.binary =
nullptr;
21678 m_type = value_t::null;
21679 assert_invariant();
21683 case value_t::object:
21685 result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator);
21689 case value_t::array:
21691 result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator);
21695 case value_t::null:
21696 case value_t::discarded:
21707 std::is_same<IteratorType, typename basic_json_t::iterator>::value ||
21708 std::is_same<IteratorType, typename basic_json_t::const_iterator>::value,
int > = 0 >
21709 IteratorType
erase(IteratorType first, IteratorType last)
21714 JSON_THROW(invalid_iterator::create(203,
"iterators do not fit current value",
this));
21717 IteratorType result = end();
21721 case value_t::boolean:
21722 case value_t::number_float:
21723 case value_t::number_integer:
21724 case value_t::number_unsigned:
21725 case value_t::string:
21726 case value_t::binary:
21729 || !last.m_it.primitive_iterator.is_end()))
21731 JSON_THROW(invalid_iterator::create(204,
"iterators out of range",
this));
21736 AllocatorType<string_t> alloc;
21737 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.string);
21738 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.string, 1);
21739 m_value.string =
nullptr;
21741 else if (is_binary())
21743 AllocatorType<binary_t> alloc;
21744 std::allocator_traits<
decltype(alloc)>::destroy(alloc, m_value.binary);
21745 std::allocator_traits<
decltype(alloc)>::deallocate(alloc, m_value.binary, 1);
21746 m_value.binary =
nullptr;
21749 m_type = value_t::null;
21750 assert_invariant();
21754 case value_t::object:
21756 result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator,
21757 last.m_it.object_iterator);
21761 case value_t::array:
21763 result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator,
21764 last.m_it.array_iterator);
21768 case value_t::null:
21769 case value_t::discarded:
21788 return m_value.object->erase(std::forward<KeyType>(key));
21801 const auto it = m_value.object->find(std::forward<KeyType>(key));
21802 if (it != m_value.object->end())
21804 m_value.object->erase(it);
21818 return erase_internal(key);
21827 return erase_internal(std::forward<KeyType>(key));
21839 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"),
this));
21842 m_value.array->erase(m_value.array->begin() +
static_cast<difference_type>(idx));
21864 auto result = end();
21868 result.m_it.object_iterator = m_value.object->find(key);
21878 auto result = cend();
21882 result.m_it.object_iterator = m_value.object->find(key);
21894 auto result = end();
21898 result.m_it.object_iterator = m_value.object->find(std::forward<KeyType>(key));
21910 auto result = cend();
21914 result.m_it.object_iterator = m_value.object->find(std::forward<KeyType>(key));
21925 return is_object() ? m_value.object->count(key) : 0;
21935 return is_object() ? m_value.object->count(std::forward<KeyType>(key)) : 0;
21940 bool contains(
const typename object_t::key_type& key)
const
21942 return is_object() && m_value.object->find(key) != m_value.object->end();
21951 return is_object() && m_value.object->find(std::forward<KeyType>(key)) != m_value.object->end();
21961 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
21963 bool contains(const typename ::nlohmann::
json_pointer<BasicJsonType>& ptr)
const
21965 return ptr.contains(
this);
21983 result.set_begin();
21999 result.set_begin();
22079 return ref.items();
22090 return ref.items();
22097 return iteration_proxy<iterator>(*
this);
22102 iteration_proxy<const_iterator>
items() const noexcept
22104 return iteration_proxy<const_iterator>(*
this);
22123 case value_t::null:
22129 case value_t::array:
22132 return m_value.array->empty();
22135 case value_t::object:
22138 return m_value.object->empty();
22141 case value_t::string:
22142 case value_t::boolean:
22143 case value_t::number_integer:
22144 case value_t::number_unsigned:
22145 case value_t::number_float:
22146 case value_t::binary:
22147 case value_t::discarded:
22162 case value_t::null:
22168 case value_t::array:
22171 return m_value.array->size();
22174 case value_t::object:
22177 return m_value.object->size();
22180 case value_t::string:
22181 case value_t::boolean:
22182 case value_t::number_integer:
22183 case value_t::number_unsigned:
22184 case value_t::number_float:
22185 case value_t::binary:
22186 case value_t::discarded:
22201 case value_t::array:
22204 return m_value.array->max_size();
22207 case value_t::object:
22210 return m_value.object->max_size();
22213 case value_t::null:
22214 case value_t::string:
22215 case value_t::boolean:
22216 case value_t::number_integer:
22217 case value_t::number_unsigned:
22218 case value_t::number_float:
22219 case value_t::binary:
22220 case value_t::discarded:
22245 case value_t::number_integer:
22247 m_value.number_integer = 0;
22251 case value_t::number_unsigned:
22253 m_value.number_unsigned = 0;
22257 case value_t::number_float:
22259 m_value.number_float = 0.0;
22263 case value_t::boolean:
22265 m_value.boolean =
false;
22269 case value_t::string:
22271 m_value.string->clear();
22275 case value_t::binary:
22277 m_value.binary->clear();
22281 case value_t::array:
22283 m_value.array->clear();
22287 case value_t::object:
22289 m_value.object->clear();
22293 case value_t::null:
22294 case value_t::discarded:
22313 m_type = value_t::array;
22314 m_value = value_t::array;
22315 assert_invariant();
22319 const auto old_capacity = m_value.array->capacity();
22320 m_value.array->push_back(std::move(val));
22321 set_parent(m_value.array->back(), old_capacity);
22329 push_back(std::move(val));
22346 m_type = value_t::array;
22347 m_value = value_t::array;
22348 assert_invariant();
22352 const auto old_capacity = m_value.array->capacity();
22353 m_value.array->push_back(val);
22354 set_parent(m_value.array->back(), old_capacity);
22378 m_type = value_t::object;
22379 m_value = value_t::object;
22380 assert_invariant();
22384 auto res = m_value.object->insert(val);
22385 set_parent(res.first->second);
22400 if (is_object() && init.size() == 2 && (*init.begin())->is_string())
22402 basic_json&& key = init.begin()->moved_or_copied();
22403 push_back(
typename object_t::value_type(
22404 std::move(key.get_ref<
string_t&>()), (init.begin() + 1)->moved_or_copied()));
22422 template<
class... Args>
22434 m_type = value_t::array;
22435 m_value = value_t::array;
22436 assert_invariant();
22440 const auto old_capacity = m_value.array->capacity();
22441 m_value.array->emplace_back(std::forward<Args>(args)...);
22442 return set_parent(m_value.array->back(), old_capacity);
22447 template<
class... Args>
22459 m_type = value_t::object;
22460 m_value = value_t::object;
22461 assert_invariant();
22465 auto res = m_value.object->emplace(std::forward<Args>(args)...);
22466 set_parent(res.first->second);
22470 it.m_it.object_iterator = res.first;
22473 return {it, res.second};
22479 template<
typename... Args>
22485 auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator);
22486 m_value.array->insert(pos.m_it.array_iterator, std::forward<Args>(args)...);
22487 result.m_it.array_iterator = m_value.array->begin() + insert_pos;
22507 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22511 return insert_iterator(pos, val);
22521 return insert(pos, val);
22534 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22538 return insert_iterator(pos, cnt, val);
22557 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22563 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22568 JSON_THROW(invalid_iterator::create(211,
"passed iterators may not belong to container",
this));
22572 return insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
22588 JSON_THROW(invalid_iterator::create(202,
"iterator does not fit current value",
this));
22592 return insert_iterator(pos, ilist.begin(), ilist.end());
22608 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22614 JSON_THROW(invalid_iterator::create(202,
"iterators first and last must point to objects",
this));
22617 m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
22624 update(j.begin(), j.end(), merge_objects);
22634 m_type = value_t::object;
22635 m_value.object = create<object_t>();
22636 assert_invariant();
22647 JSON_THROW(invalid_iterator::create(210,
"iterators do not fit",
this));
22653 JSON_THROW(type_error::create(312,
detail::concat(
"cannot use update() with ", first.m_object->type_name()), first.m_object));
22656 for (
auto it = first; it != last; ++it)
22658 if (merge_objects && it.value().is_object())
22660 auto it2 = m_value.object->find(it.key());
22661 if (it2 != m_value.object->end())
22663 it2->second.update(it.value(),
true);
22667 m_value.object->operator[](it.key()) = it.value();
22668#if JSON_DIAGNOSTICS
22669 m_value.object->operator[](it.key()).m_parent =
this;
22677 std::is_nothrow_move_constructible<value_t>::value&&
22678 std::is_nothrow_move_assignable<value_t>::value&&
22679 std::is_nothrow_move_constructible<json_value>::value&&
22680 std::is_nothrow_move_assignable<json_value>::value
22687 other.set_parents();
22688 assert_invariant();
22694 std::is_nothrow_move_constructible<value_t>::value&&
22695 std::is_nothrow_move_assignable<value_t>::value&&
22696 std::is_nothrow_move_constructible<json_value>::value&&
22697 std::is_nothrow_move_assignable<json_value>::value
22711 swap(*(m_value.array), other);
22727 swap(*(m_value.object), other);
22743 swap(*(m_value.string), other);
22759 swap(*(m_value.binary), other);
22769 void swap(
typename binary_t::container_type& other)
22775 swap(*(m_value.binary), other);
22779 JSON_THROW(type_error::create(310,
detail::concat(
"cannot use swap(binary_t::container_type&) with ", type_name()),
this));
22794#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result) \
22795 const auto lhs_type = lhs.type(); \
22796 const auto rhs_type = rhs.type(); \
22798 if (lhs_type == rhs_type) \
22800 switch (lhs_type) \
22802 case value_t::array: \
22803 return (*lhs.m_value.array) op (*rhs.m_value.array); \
22805 case value_t::object: \
22806 return (*lhs.m_value.object) op (*rhs.m_value.object); \
22808 case value_t::null: \
22809 return (null_result); \
22811 case value_t::string: \
22812 return (*lhs.m_value.string) op (*rhs.m_value.string); \
22814 case value_t::boolean: \
22815 return (lhs.m_value.boolean) op (rhs.m_value.boolean); \
22817 case value_t::number_integer: \
22818 return (lhs.m_value.number_integer) op (rhs.m_value.number_integer); \
22820 case value_t::number_unsigned: \
22821 return (lhs.m_value.number_unsigned) op (rhs.m_value.number_unsigned); \
22823 case value_t::number_float: \
22824 return (lhs.m_value.number_float) op (rhs.m_value.number_float); \
22826 case value_t::binary: \
22827 return (*lhs.m_value.binary) op (*rhs.m_value.binary); \
22829 case value_t::discarded: \
22831 return (unordered_result); \
22834 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) \
22836 return static_cast<number_float_t>(lhs.m_value.number_integer) op rhs.m_value.number_float; \
22838 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) \
22840 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_integer); \
22842 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) \
22844 return static_cast<number_float_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_float; \
22846 else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) \
22848 return lhs.m_value.number_float op static_cast<number_float_t>(rhs.m_value.number_unsigned); \
22850 else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) \
22852 return static_cast<number_integer_t>(lhs.m_value.number_unsigned) op rhs.m_value.number_integer; \
22854 else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) \
22856 return lhs.m_value.number_integer op static_cast<number_integer_t>(rhs.m_value.number_unsigned); \
22858 else if(compares_unordered(lhs, rhs))\
22860 return (unordered_result);\
22863 return (default_result);
22871 static bool compares_unordered(const_reference lhs, const_reference rhs,
bool inverse =
false) noexcept
22873 if ((lhs.is_number_float() && std::isnan(lhs.m_value.number_float) && rhs.is_number())
22874 || (rhs.is_number_float() && std::isnan(rhs.m_value.number_float) && lhs.is_number()))
22878#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22879 return (lhs.is_discarded() || rhs.is_discarded()) && !inverse;
22881 static_cast<void>(inverse);
22882 return lhs.is_discarded() || rhs.is_discarded();
22887 bool compares_unordered(const_reference rhs,
bool inverse =
false) const noexcept
22889 return compares_unordered(*
this, rhs, inverse);
22893#if JSON_HAS_THREE_WAY_COMPARISON
22896 bool operator==(const_reference rhs)
const noexcept
22899#pragma GCC diagnostic push
22900#pragma GCC diagnostic ignored "-Wfloat-equal"
22902 const_reference lhs = *
this;
22905#pragma GCC diagnostic pop
22911 template<
typename ScalarType>
22912 requires std::is_scalar_v<ScalarType>
22913 bool operator==(ScalarType rhs)
const noexcept
22920 bool operator!=(const_reference rhs)
const noexcept
22922 if (compares_unordered(rhs,
true))
22931 std::partial_ordering operator<=>(const_reference rhs)
const noexcept
22933 const_reference lhs = *
this;
22937 std::partial_ordering::equivalent,
22938 std::partial_ordering::unordered,
22939 lhs_type <=> rhs_type)
22944 template<
typename ScalarType>
22945 requires std::is_scalar_v<ScalarType>
22946 std::partial_ordering operator<=>(ScalarType rhs)
const noexcept
22951#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
22958 bool operator<=(const_reference rhs)
const noexcept
22960 if (compares_unordered(rhs,
true))
22964 return !(rhs < *
this);
22969 template<
typename ScalarType>
22970 requires std::is_scalar_v<ScalarType>
22971 bool operator<=(ScalarType rhs)
const noexcept
22979 bool operator>=(const_reference rhs)
const noexcept
22981 if (compares_unordered(rhs,
true))
22985 return !(*
this < rhs);
22990 template<
typename ScalarType>
22991 requires std::is_scalar_v<ScalarType>
22992 bool operator>=(ScalarType rhs)
const noexcept
23000 friend bool operator==(const_reference lhs, const_reference rhs)
noexcept
23003#pragma GCC diagnostic push
23004#pragma GCC diagnostic ignored "-Wfloat-equal"
23008#pragma GCC diagnostic pop
23014 template<
typename ScalarType,
typename std::enable_if<
23015 std::is_scalar<ScalarType>::value,
int>::type = 0>
23016 friend bool operator==(const_reference lhs, ScalarType rhs)
noexcept
23023 template<
typename ScalarType,
typename std::enable_if<
23024 std::is_scalar<ScalarType>::value,
int>::type = 0>
23025 friend bool operator==(ScalarType lhs, const_reference rhs)
noexcept
23032 friend bool operator!=(const_reference lhs, const_reference rhs)
noexcept
23034 if (compares_unordered(lhs, rhs,
true))
23038 return !(lhs == rhs);
23043 template<
typename ScalarType,
typename std::enable_if<
23044 std::is_scalar<ScalarType>::value,
int>::type = 0>
23045 friend bool operator!=(const_reference lhs, ScalarType rhs)
noexcept
23052 template<
typename ScalarType,
typename std::enable_if<
23053 std::is_scalar<ScalarType>::value,
int>::type = 0>
23054 friend bool operator!=(ScalarType lhs, const_reference rhs)
noexcept
23061 friend bool operator<(const_reference lhs, const_reference rhs)
noexcept
23071 template<
typename ScalarType,
typename std::enable_if<
23072 std::is_scalar<ScalarType>::value,
int>::type = 0>
23073 friend bool operator<(const_reference lhs, ScalarType rhs)
noexcept
23080 template<
typename ScalarType,
typename std::enable_if<
23081 std::is_scalar<ScalarType>::value,
int>::type = 0>
23082 friend bool operator<(ScalarType lhs, const_reference rhs)
noexcept
23089 friend bool operator<=(const_reference lhs, const_reference rhs)
noexcept
23091 if (compares_unordered(lhs, rhs,
true))
23095 return !(rhs < lhs);
23100 template<
typename ScalarType,
typename std::enable_if<
23101 std::is_scalar<ScalarType>::value,
int>::type = 0>
23102 friend bool operator<=(const_reference lhs, ScalarType rhs)
noexcept
23109 template<
typename ScalarType,
typename std::enable_if<
23110 std::is_scalar<ScalarType>::value,
int>::type = 0>
23111 friend bool operator<=(ScalarType lhs, const_reference rhs)
noexcept
23118 friend bool operator>(const_reference lhs, const_reference rhs)
noexcept
23121 if (compares_unordered(lhs, rhs))
23125 return !(lhs <= rhs);
23130 template<
typename ScalarType,
typename std::enable_if<
23131 std::is_scalar<ScalarType>::value,
int>::type = 0>
23132 friend bool operator>(const_reference lhs, ScalarType rhs)
noexcept
23139 template<
typename ScalarType,
typename std::enable_if<
23140 std::is_scalar<ScalarType>::value,
int>::type = 0>
23141 friend bool operator>(ScalarType lhs, const_reference rhs)
noexcept
23148 friend bool operator>=(const_reference lhs, const_reference rhs)
noexcept
23150 if (compares_unordered(lhs, rhs,
true))
23154 return !(lhs < rhs);
23159 template<
typename ScalarType,
typename std::enable_if<
23160 std::is_scalar<ScalarType>::value,
int>::type = 0>
23161 friend bool operator>=(const_reference lhs, ScalarType rhs)
noexcept
23168 template<
typename ScalarType,
typename std::enable_if<
23169 std::is_scalar<ScalarType>::value,
int>::type = 0>
23170 friend bool operator>=(ScalarType lhs, const_reference rhs)
noexcept
23176#undef JSON_IMPLEMENT_OPERATOR
23192 const bool pretty_print = o.width() > 0;
23193 const auto indentation = pretty_print ? o.width() : 0;
23200 s.dump(j, pretty_print,
false,
static_cast<unsigned int>(indentation));
23228 template<
typename InputType>
23231 const parser_callback_t cb =
nullptr,
23232 const bool allow_exceptions =
true,
23233 const bool ignore_comments =
false)
23236 parser(
detail::input_adapter(std::forward<InputType>(i)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23242 template<
typename IteratorType>
23246 const parser_callback_t cb =
nullptr,
23247 const bool allow_exceptions =
true,
23248 const bool ignore_comments =
false)
23251 parser(
detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(
true, result);
23258 const parser_callback_t cb =
nullptr,
23259 const bool allow_exceptions =
true,
23260 const bool ignore_comments =
false)
23263 parser(i.get(), cb, allow_exceptions, ignore_comments).parse(
true, result);
23269 template<
typename InputType>
23270 static bool accept(InputType&& i,
23271 const bool ignore_comments =
false)
23273 return parser(
detail::input_adapter(std::forward<InputType>(i)),
nullptr,
false, ignore_comments).accept(
true);
23278 template<
typename IteratorType>
23279 static bool accept(IteratorType first, IteratorType last,
23280 const bool ignore_comments =
false)
23282 return parser(
detail::input_adapter(std::move(first), std::move(last)),
nullptr,
false, ignore_comments).accept(
true);
23288 const bool ignore_comments =
false)
23290 return parser(i.get(),
nullptr,
false, ignore_comments).accept(
true);
23295 template <
typename InputType,
typename SAX>
23297 static
bool sax_parse(InputType&& i, SAX* sax,
23299 const
bool strict = true,
23300 const
bool ignore_comments = false)
23303 return format == input_format_t::json
23304 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23310 template<
class IteratorType,
class SAX>
23312 static
bool sax_parse(IteratorType first, IteratorType last, SAX* sax,
23314 const
bool strict = true,
23315 const
bool ignore_comments = false)
23318 return format == input_format_t::json
23319 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23328 template <
typename SAX>
23331 static
bool sax_parse(
detail::span_input_adapter&& i, SAX* sax,
23333 const
bool strict = true,
23334 const
bool ignore_comments = false)
23337 return format == input_format_t::json
23339 ? parser(std::move(ia),
nullptr,
true, ignore_comments).sax_parse(sax, strict)
23353 return operator>>(i, j);
23377 case value_t::null:
23379 case value_t::object:
23381 case value_t::array:
23383 case value_t::string:
23385 case value_t::boolean:
23387 case value_t::binary:
23389 case value_t::discarded:
23390 return "discarded";
23391 case value_t::number_integer:
23392 case value_t::number_unsigned:
23393 case value_t::number_float:
23406 value_t m_type = value_t::null;
23409 json_value m_value = {};
23411#if JSON_DIAGNOSTICS
23428 std::vector<std::uint8_t> result;
23429 to_cbor(j, result);
23437 binary_writer<std::uint8_t>(o).write_cbor(j);
23444 binary_writer<char>(o).write_cbor(j);
23451 std::vector<std::uint8_t> result;
23452 to_msgpack(j, result);
23460 binary_writer<std::uint8_t>(o).write_msgpack(j);
23467 binary_writer<char>(o).write_msgpack(j);
23473 const bool use_size =
false,
23474 const bool use_type =
false)
23476 std::vector<std::uint8_t> result;
23477 to_ubjson(j, result, use_size, use_type);
23484 const bool use_size =
false,
const bool use_type =
false)
23486 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type);
23492 const bool use_size =
false,
const bool use_type =
false)
23494 binary_writer<char>(o).write_ubjson(j, use_size, use_type);
23500 const bool use_size =
false,
23501 const bool use_type =
false)
23503 std::vector<std::uint8_t> result;
23504 to_bjdata(j, result, use_size, use_type);
23511 const bool use_size =
false,
const bool use_type =
false)
23513 binary_writer<std::uint8_t>(o).write_ubjson(j, use_size, use_type,
true,
true);
23519 const bool use_size =
false,
const bool use_type =
false)
23521 binary_writer<char>(o).write_ubjson(j, use_size, use_type,
true,
true);
23528 std::vector<std::uint8_t> result;
23529 to_bson(j, result);
23537 binary_writer<std::uint8_t>(o).write_bson(j);
23544 binary_writer<char>(o).write_bson(j);
23549 template<
typename InputType>
23552 const bool strict =
true,
23553 const bool allow_exceptions =
true,
23559 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23560 return res ? result :
basic_json(value_t::discarded);
23565 template<
typename IteratorType>
23568 const bool strict =
true,
23569 const bool allow_exceptions =
true,
23575 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23576 return res ? result :
basic_json(value_t::discarded);
23579 template<
typename T>
23583 const
bool strict = true,
23584 const
bool allow_exceptions = true,
23587 return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler);
23594 const
bool strict = true,
23595 const
bool allow_exceptions = true,
23602 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::cbor).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler);
23603 return res ? result :
basic_json(value_t::discarded);
23608 template<
typename InputType>
23611 const bool strict =
true,
23612 const bool allow_exceptions =
true)
23617 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23618 return res ? result :
basic_json(value_t::discarded);
23623 template<
typename IteratorType>
23626 const bool strict =
true,
23627 const bool allow_exceptions =
true)
23632 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23633 return res ? result :
basic_json(value_t::discarded);
23636 template<
typename T>
23640 const
bool strict = true,
23641 const
bool allow_exceptions = true)
23643 return from_msgpack(ptr, ptr + len, strict, allow_exceptions);
23649 const
bool strict = true,
23650 const
bool allow_exceptions = true)
23656 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::msgpack).sax_parse(input_format_t::msgpack, &sdp, strict);
23657 return res ? result :
basic_json(value_t::discarded);
23662 template<
typename InputType>
23665 const bool strict =
true,
23666 const bool allow_exceptions =
true)
23671 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23672 return res ? result :
basic_json(value_t::discarded);
23677 template<
typename IteratorType>
23680 const bool strict =
true,
23681 const bool allow_exceptions =
true)
23686 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23687 return res ? result :
basic_json(value_t::discarded);
23690 template<
typename T>
23694 const
bool strict = true,
23695 const
bool allow_exceptions = true)
23697 return from_ubjson(ptr, ptr + len, strict, allow_exceptions);
23703 const
bool strict = true,
23704 const
bool allow_exceptions = true)
23710 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::ubjson).sax_parse(input_format_t::ubjson, &sdp, strict);
23711 return res ? result :
basic_json(value_t::discarded);
23717 template<
typename InputType>
23720 const bool strict =
true,
23721 const bool allow_exceptions =
true)
23726 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23727 return res ? result :
basic_json(value_t::discarded);
23732 template<
typename IteratorType>
23735 const bool strict =
true,
23736 const bool allow_exceptions =
true)
23741 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bjdata).sax_parse(input_format_t::bjdata, &sdp, strict);
23742 return res ? result :
basic_json(value_t::discarded);
23747 template<
typename InputType>
23750 const bool strict =
true,
23751 const bool allow_exceptions =
true)
23756 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23757 return res ? result :
basic_json(value_t::discarded);
23762 template<
typename IteratorType>
23765 const bool strict =
true,
23766 const bool allow_exceptions =
true)
23771 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23772 return res ? result :
basic_json(value_t::discarded);
23775 template<
typename T>
23779 const
bool strict = true,
23780 const
bool allow_exceptions = true)
23782 return from_bson(ptr, ptr + len, strict, allow_exceptions);
23788 const
bool strict = true,
23789 const
bool allow_exceptions = true)
23795 const bool res = binary_reader<decltype(ia)>(std::move(ia), input_format_t::bson).sax_parse(input_format_t::bson, &sdp, strict);
23796 return res ? result :
basic_json(value_t::discarded);
23814 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23818 return ptr.get_unchecked(
this);
23828 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23832 return ptr.get_unchecked(
this);
23842 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23846 return ptr.get_checked(
this);
23856 template<typename BasicJsonType, detail::enable_if_t<detail::is_basic_json<BasicJsonType>::value,
int> = 0>
23860 return ptr.get_checked(
this);
23894 enum class patch_operations {add, remove, replace, move, copy, test, invalid};
23896 const auto get_op = [](
const std::string & op)
23900 return patch_operations::add;
23902 if (op ==
"remove")
23904 return patch_operations::remove;
23906 if (op ==
"replace")
23908 return patch_operations::replace;
23912 return patch_operations::move;
23916 return patch_operations::copy;
23920 return patch_operations::test;
23923 return patch_operations::invalid;
23938 if (top_pointer != ptr)
23940 result.
at(top_pointer);
23944 const auto last_path = ptr.
back();
23949 switch (parent.m_type)
23951 case value_t::null:
23952 case value_t::object:
23955 parent[last_path] = val;
23959 case value_t::array:
23961 if (last_path ==
"-")
23968 const auto idx = json_pointer::template array_index<basic_json_t>(last_path);
23972 JSON_THROW(out_of_range::create(401,
detail::concat(
"array index ", std::to_string(idx),
" is out of range"), &parent));
23982 case value_t::string:
23983 case value_t::boolean:
23984 case value_t::number_integer:
23985 case value_t::number_unsigned:
23986 case value_t::number_float:
23987 case value_t::binary:
23988 case value_t::discarded:
23995 const auto operation_remove = [
this, &result](
json_pointer & ptr)
23998 const auto last_path = ptr.
back();
24006 auto it = parent.
find(last_path);
24019 parent.
erase(json_pointer::template array_index<basic_json_t>(last_path));
24026 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &json_patch));
24030 for (
const auto& val : json_patch)
24033 const auto get_value = [&val](
const std::string & op,
24034 const std::string & member,
24038 auto it = val.
m_value.object->find(member);
24041 const auto error_msg = (op ==
"op") ?
"operation" :
detail::concat(
"operation '", op,
'\'');
24054 JSON_THROW(parse_error::create(105, 0,
detail::concat(error_msg,
" must have string member '", member,
"'"), &val));
24064 JSON_THROW(parse_error::create(104, 0,
"JSON patch must be an array of objects", &val));
24068 const auto op = get_value(
"op",
"op",
true).template get<std::string>();
24069 const auto path = get_value(op,
"path",
true).template get<std::string>();
24072 switch (get_op(op))
24074 case patch_operations::add:
24076 operation_add(ptr, get_value(
"add",
"value",
false));
24080 case patch_operations::remove:
24082 operation_remove(ptr);
24086 case patch_operations::replace:
24089 result.
at(ptr) = get_value(
"replace",
"value",
false);
24093 case patch_operations::move:
24095 const auto from_path = get_value(
"move",
"from",
true).template get<std::string>();
24105 operation_remove(from_ptr);
24106 operation_add(ptr, v);
24110 case patch_operations::copy:
24112 const auto from_path = get_value(
"copy",
"from",
true).template get<std::string>();
24121 operation_add(ptr, v);
24125 case patch_operations::test:
24127 bool success =
false;
24132 success = (result.
at(ptr) == get_value(
"test",
"value",
false));
24148 case patch_operations::invalid:
24172 const std::string& path =
"")
24178 if (source == target)
24183 if (source.type() != target.type())
24188 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24193 switch (source.type())
24195 case value_t::array:
24199 while (i < source.size() && i < target.size())
24202 auto temp_diff = diff(source[i], target[i],
detail::concat(path,
'/', std::to_string(i)));
24203 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24212 while (i < source.size())
24216 result.
insert(result.
begin() + end_index, object(
24225 while (i < target.size())
24231 {
"value", target[i]}
24239 case value_t::object:
24242 for (
auto it = source.cbegin(); it != source.cend(); ++it)
24247 if (target.find(it.key()) != target.end())
24250 auto temp_diff = diff(it.value(), target[it.key()], path_key);
24251 result.
insert(result.
end(), temp_diff.begin(), temp_diff.end());
24258 {
"op",
"remove"}, {
"path", path_key}
24264 for (
auto it = target.cbegin(); it != target.cend(); ++it)
24266 if (source.find(it.key()) == source.end())
24272 {
"op",
"add"}, {
"path", path_key},
24273 {
"value", it.value()}
24281 case value_t::null:
24282 case value_t::string:
24283 case value_t::boolean:
24284 case value_t::number_integer:
24285 case value_t::number_unsigned:
24286 case value_t::number_float:
24287 case value_t::binary:
24288 case value_t::discarded:
24294 {
"op",
"replace"}, {
"path", path}, {
"value", target}
24315 if (apply_patch.is_object())
24321 for (
auto it = apply_patch.begin(); it != apply_patch.end(); ++it)
24323 if (it.value().is_null())
24329 operator[](it.key()).merge_patch(it.value());
24335 *
this = apply_patch;
24352inline namespace json_literals
24358inline nlohmann::
json operator "" _json(const
char* s,
std::
size_t n)
24360 return nlohmann::json::parse(s, s + n);
24366inline nlohmann::
json::
json_pointer operator "" _json_pointer(const
char* s,
std::
size_t n)
24389 return nlohmann::detail::hash(j);
24395struct less< ::nlohmann::detail::value_t>
24402 ::nlohmann::detail::value_t rhs)
const noexcept
24404#if JSON_HAS_THREE_WAY_COMPARISON
24405 return std::is_lt(lhs <=> rhs);
24407 return ::nlohmann::detail::operator<(lhs, rhs);
24413#ifndef JSON_HAS_CPP_20
24418inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC_JSON_TPL& j2)
noexcept(
24419 is_nothrow_move_constructible<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value&&
24420 is_nothrow_move_assignable<nlohmann::NLOHMANN_BASIC_JSON_TPL>::value)
24429#if JSON_USE_GLOBAL_UDLS
24430 using nlohmann::literals::json_literals::operator
"" _json;
24431 using nlohmann::literals::json_literals::operator
"" _json_pointer;
24446#if defined(__clang__)
24447 #pragma clang diagnostic pop
24452#undef JSON_INTERNAL_CATCH
24454#undef JSON_PRIVATE_UNLESS_TESTED
24455#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION
24456#undef NLOHMANN_BASIC_JSON_TPL
24457#undef JSON_EXPLICIT
24458#undef NLOHMANN_CAN_CALL_STD_FUNC_IMPL
24459#undef JSON_INLINE_VARIABLE
24460#undef JSON_NO_UNIQUE_ADDRESS
24461#undef JSON_DISABLE_ENUM_SERIALIZATION
24462#undef JSON_USE_GLOBAL_UDLS
24464#ifndef JSON_TEST_KEEP_MACROS
24467 #undef JSON_HAS_CPP_11
24468 #undef JSON_HAS_CPP_14
24469 #undef JSON_HAS_CPP_17
24470 #undef JSON_HAS_CPP_20
24471 #undef JSON_HAS_FILESYSTEM
24472 #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM
24473 #undef JSON_HAS_THREE_WAY_COMPARISON
24474 #undef JSON_HAS_RANGES
24475 #undef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
24489#undef JSON_HEDLEY_ALWAYS_INLINE
24490#undef JSON_HEDLEY_ARM_VERSION
24491#undef JSON_HEDLEY_ARM_VERSION_CHECK
24492#undef JSON_HEDLEY_ARRAY_PARAM
24493#undef JSON_HEDLEY_ASSUME
24494#undef JSON_HEDLEY_BEGIN_C_DECLS
24495#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE
24496#undef JSON_HEDLEY_CLANG_HAS_BUILTIN
24497#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
24498#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
24499#undef JSON_HEDLEY_CLANG_HAS_EXTENSION
24500#undef JSON_HEDLEY_CLANG_HAS_FEATURE
24501#undef JSON_HEDLEY_CLANG_HAS_WARNING
24502#undef JSON_HEDLEY_COMPCERT_VERSION
24503#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK
24504#undef JSON_HEDLEY_CONCAT
24505#undef JSON_HEDLEY_CONCAT3
24506#undef JSON_HEDLEY_CONCAT3_EX
24507#undef JSON_HEDLEY_CONCAT_EX
24508#undef JSON_HEDLEY_CONST
24509#undef JSON_HEDLEY_CONSTEXPR
24510#undef JSON_HEDLEY_CONST_CAST
24511#undef JSON_HEDLEY_CPP_CAST
24512#undef JSON_HEDLEY_CRAY_VERSION
24513#undef JSON_HEDLEY_CRAY_VERSION_CHECK
24514#undef JSON_HEDLEY_C_DECL
24515#undef JSON_HEDLEY_DEPRECATED
24516#undef JSON_HEDLEY_DEPRECATED_FOR
24517#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
24518#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
24519#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
24520#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
24521#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
24522#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION
24523#undef JSON_HEDLEY_DIAGNOSTIC_POP
24524#undef JSON_HEDLEY_DIAGNOSTIC_PUSH
24525#undef JSON_HEDLEY_DMC_VERSION
24526#undef JSON_HEDLEY_DMC_VERSION_CHECK
24527#undef JSON_HEDLEY_EMPTY_BASES
24528#undef JSON_HEDLEY_EMSCRIPTEN_VERSION
24529#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK
24530#undef JSON_HEDLEY_END_C_DECLS
24531#undef JSON_HEDLEY_FLAGS
24532#undef JSON_HEDLEY_FLAGS_CAST
24533#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE
24534#undef JSON_HEDLEY_GCC_HAS_BUILTIN
24535#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE
24536#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
24537#undef JSON_HEDLEY_GCC_HAS_EXTENSION
24538#undef JSON_HEDLEY_GCC_HAS_FEATURE
24539#undef JSON_HEDLEY_GCC_HAS_WARNING
24540#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
24541#undef JSON_HEDLEY_GCC_VERSION
24542#undef JSON_HEDLEY_GCC_VERSION_CHECK
24543#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE
24544#undef JSON_HEDLEY_GNUC_HAS_BUILTIN
24545#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
24546#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
24547#undef JSON_HEDLEY_GNUC_HAS_EXTENSION
24548#undef JSON_HEDLEY_GNUC_HAS_FEATURE
24549#undef JSON_HEDLEY_GNUC_HAS_WARNING
24550#undef JSON_HEDLEY_GNUC_VERSION
24551#undef JSON_HEDLEY_GNUC_VERSION_CHECK
24552#undef JSON_HEDLEY_HAS_ATTRIBUTE
24553#undef JSON_HEDLEY_HAS_BUILTIN
24554#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE
24555#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS
24556#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE
24557#undef JSON_HEDLEY_HAS_EXTENSION
24558#undef JSON_HEDLEY_HAS_FEATURE
24559#undef JSON_HEDLEY_HAS_WARNING
24560#undef JSON_HEDLEY_IAR_VERSION
24561#undef JSON_HEDLEY_IAR_VERSION_CHECK
24562#undef JSON_HEDLEY_IBM_VERSION
24563#undef JSON_HEDLEY_IBM_VERSION_CHECK
24564#undef JSON_HEDLEY_IMPORT
24565#undef JSON_HEDLEY_INLINE
24566#undef JSON_HEDLEY_INTEL_CL_VERSION
24567#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK
24568#undef JSON_HEDLEY_INTEL_VERSION
24569#undef JSON_HEDLEY_INTEL_VERSION_CHECK
24570#undef JSON_HEDLEY_IS_CONSTANT
24571#undef JSON_HEDLEY_IS_CONSTEXPR_
24572#undef JSON_HEDLEY_LIKELY
24573#undef JSON_HEDLEY_MALLOC
24574#undef JSON_HEDLEY_MCST_LCC_VERSION
24575#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK
24576#undef JSON_HEDLEY_MESSAGE
24577#undef JSON_HEDLEY_MSVC_VERSION
24578#undef JSON_HEDLEY_MSVC_VERSION_CHECK
24579#undef JSON_HEDLEY_NEVER_INLINE
24580#undef JSON_HEDLEY_NON_NULL
24581#undef JSON_HEDLEY_NO_ESCAPE
24582#undef JSON_HEDLEY_NO_RETURN
24583#undef JSON_HEDLEY_NO_THROW
24584#undef JSON_HEDLEY_NULL
24585#undef JSON_HEDLEY_PELLES_VERSION
24586#undef JSON_HEDLEY_PELLES_VERSION_CHECK
24587#undef JSON_HEDLEY_PGI_VERSION
24588#undef JSON_HEDLEY_PGI_VERSION_CHECK
24589#undef JSON_HEDLEY_PREDICT
24590#undef JSON_HEDLEY_PRINTF_FORMAT
24591#undef JSON_HEDLEY_PRIVATE
24592#undef JSON_HEDLEY_PUBLIC
24593#undef JSON_HEDLEY_PURE
24594#undef JSON_HEDLEY_REINTERPRET_CAST
24595#undef JSON_HEDLEY_REQUIRE
24596#undef JSON_HEDLEY_REQUIRE_CONSTEXPR
24597#undef JSON_HEDLEY_REQUIRE_MSG
24598#undef JSON_HEDLEY_RESTRICT
24599#undef JSON_HEDLEY_RETURNS_NON_NULL
24600#undef JSON_HEDLEY_SENTINEL
24601#undef JSON_HEDLEY_STATIC_ASSERT
24602#undef JSON_HEDLEY_STATIC_CAST
24603#undef JSON_HEDLEY_STRINGIFY
24604#undef JSON_HEDLEY_STRINGIFY_EX
24605#undef JSON_HEDLEY_SUNPRO_VERSION
24606#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK
24607#undef JSON_HEDLEY_TINYC_VERSION
24608#undef JSON_HEDLEY_TINYC_VERSION_CHECK
24609#undef JSON_HEDLEY_TI_ARMCL_VERSION
24610#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK
24611#undef JSON_HEDLEY_TI_CL2000_VERSION
24612#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK
24613#undef JSON_HEDLEY_TI_CL430_VERSION
24614#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK
24615#undef JSON_HEDLEY_TI_CL6X_VERSION
24616#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK
24617#undef JSON_HEDLEY_TI_CL7X_VERSION
24618#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK
24619#undef JSON_HEDLEY_TI_CLPRU_VERSION
24620#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK
24621#undef JSON_HEDLEY_TI_VERSION
24622#undef JSON_HEDLEY_TI_VERSION_CHECK
24623#undef JSON_HEDLEY_UNAVAILABLE
24624#undef JSON_HEDLEY_UNLIKELY
24625#undef JSON_HEDLEY_UNPREDICTABLE
24626#undef JSON_HEDLEY_UNREACHABLE
24627#undef JSON_HEDLEY_UNREACHABLE_RETURN
24628#undef JSON_HEDLEY_VERSION
24629#undef JSON_HEDLEY_VERSION_DECODE_MAJOR
24630#undef JSON_HEDLEY_VERSION_DECODE_MINOR
24631#undef JSON_HEDLEY_VERSION_DECODE_REVISION
24632#undef JSON_HEDLEY_VERSION_ENCODE
24633#undef JSON_HEDLEY_WARNING
24634#undef JSON_HEDLEY_WARN_UNUSED_RESULT
24635#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG
24636#undef JSON_HEDLEY_FALL_THROUGH
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_CONST
#define JSON_INLINE_VARIABLE
#define JSON_HEDLEY_WARN_UNUSED_RESULT
#define JSON_PRIVATE_UNLESS_TESTED
#define NLOHMANN_JSON_VERSION_PATCH
#define JSON_HEDLEY_LIKELY(expr)
#define JSON_HEDLEY_NON_NULL(...)
#define JSON_INTERNAL_CATCH(exception)
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
#define JSON_HEDLEY_RETURNS_NON_NULL
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_CATCH(exception)
#define JSON_THROW(exception)
#define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON
#define NLOHMANN_JSON_VERSION_MAJOR
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define JSON_BINARY_READER_MAKE_BJD_TYPES_MAP_
#define JSON_NO_UNIQUE_ADDRESS
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
basic_json< nlohmann::ordered_map > ordered_json
specialization that maintains the insertion order of object keys
#define NLOHMANN_JSON_VERSION_MINOR
#define JSON_BINARY_READER_MAKE_BJD_OPTIMIZED_TYPE_MARKERS_
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_IMPLEMENT_OPERATOR(op, null_result, unordered_result, default_result)
#define __GNUC_PATCHLEVEL__
namespace for Niels Lohmann
constexpr bool is_string() const noexcept
return whether value is a string
reference set_parent(reference j, std::size_t old_capacity=static_cast< std::size_t >(-1))
number_integer_t * get_impl_ptr(number_integer_t *) noexcept
get a pointer to the value (integer number)
size_type erase(const typename object_t::key_type &key)
remove element from a JSON object given a key
reference operator[](KeyType &&key)
access specified object element
json_value(object_t &&value)
constructor for rvalue objects
size_type size() const noexcept
returns the number of elements
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
json_value(typename binary_t::container_type &&value)
constructor for rvalue binary arrays
static std::vector< std::uint8_t > to_bjdata(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
auto get() const noexcept(noexcept(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))) -> decltype(std::declval< const basic_json_t & >().template get_impl< ValueType >(detail::priority_tag< 4 > {}))
get a (pointer) value (explicit)
::nlohmann::detail::iteration_proxy< Iterator > iteration_proxy
const_iterator end() const noexcept
returns an iterator to one past the last element
reference back()
access the last element
basic_json(CompatibleType &&val) noexcept(noexcept(//NOLINT(bugprone-forwarding-reference-overload, bugprone-exception-escape) JSONSerializer< U >::to_json(std::declval< basic_json_t & >(), std::forward< CompatibleType >(val))))
create a JSON value from compatible types
reverse_iterator rbegin() noexcept
returns an iterator to the reverse-beginning
basic_json patch(const basic_json &json_patch) const
applies a JSON patch to a copy of the current object
json_value(const array_t &value)
constructor for arrays
array_t * get_impl_ptr(array_t *) noexcept
get a pointer to the value (array)
JSON_HEDLEY_RETURNS_NON_NULL const char * type_name() const noexcept
return the type as string
const_reference front() const
access the first element
constexpr bool is_array() const noexcept
return whether value is an array
number_float_t * get_impl_ptr(number_float_t *) noexcept
get a pointer to the value (floating-point number)
std::conditional< detail::is_c_string_uncvref< ValueType >::value, string_t, typename std::decay< ValueType >::type > value_return_type
ReturnType value(const json_pointer &ptr, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
size_type count(KeyType &&key) const
returns the number of occurrences of a key in a JSON object
constexpr const number_integer_t * get_impl_ptr(const number_integer_t *) const noexcept
get a pointer to the value (integer number)
iter_impl< const basic_json > const_iterator
a const iterator for a basic_json container
static void to_bjdata(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
constexpr bool is_number_integer() const noexcept
return whether value is an integer number
json_reverse_iterator< typename basic_json::const_iterator > const_reverse_iterator
a const reverse iterator for a basic_json container
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
::nlohmann::detail::json_base_class< CustomBaseClass > json_base_class_t
basic_json get_impl(detail::priority_tag< 3 >) const
get special-case overload
static void to_bjdata(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a BJData serialization of a given JSON value
reference operator[](const json_pointer &ptr)
access specified element via JSON Pointer
typename std::allocator_traits< allocator_type >::const_pointer const_pointer
the type of an element const pointer
static JSON_HEDLEY_RETURNS_NON_NULL T * create(Args &&... args)
helper for exception-safe object creation
void swap(reference other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
std::size_t size_type
a type to represent container sizes
constexpr bool is_structured() const noexcept
return whether type is structured
json_value(boolean_t v) noexcept
constructor for booleans
const_reference operator[](KeyType &&key) const
access specified object element
boolean_t get_impl(boolean_t *) const
get a boolean (explicit)
void swap(binary_t &other)
exchanges the values
ReferenceType get_ref()
get a reference value (implicit)
size_type max_size() const noexcept
returns the maximum possible number of elements
void update(const_reference j, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
::nlohmann::detail::iter_impl< BasicJsonType > iter_impl
ReferenceType get_ref() const
get a reference value (implicit)
constexpr bool is_discarded() const noexcept
return whether value is discarded
reference operator+=(initializer_list_t init)
add an object to an object
::nlohmann::detail::output_adapter_t< CharType > output_adapter_t
void push_back(basic_json &&val)
add an object to an array
const_reference operator[](const typename object_t::key_type &key) const
access specified object element
iteration_proxy< const_iterator > items() const noexcept
helper to access iterator member functions in range-based for
json_value(number_integer_t v) noexcept
constructor for numbers (integer)
static ReferenceType get_ref_impl(ThisType &obj)
helper function to implement get_ref()
::nlohmann::detail::json_reverse_iterator< Base > json_reverse_iterator
const_reference back() const
access the last element
IteratorType erase(IteratorType first, IteratorType last)
remove elements given an iterator range
reference operator+=(const basic_json &val)
add an object to an array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
constexpr const string_t * get_impl_ptr(const string_t *) const noexcept
get a pointer to the value (string)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
iterator insert(const_iterator pos, size_type cnt, const basic_json &val)
inserts copies of element into array
object_t * get_impl_ptr(object_t *) noexcept
get a pointer to the value (object)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bson(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BSON format
static allocator_type get_allocator()
returns the allocator associated with the container
nlohmann::byte_container_with_subtype< BinaryType > binary_t
a type for a packed binary type
reference at(KeyType &&key)
access specified object element with bounds checking
iterator end() noexcept
returns an iterator to one past the last element
constexpr bool is_number_unsigned() const noexcept
return whether value is an unsigned integer number
json_value(array_t &&value)
constructor for rvalue arrays
void update(const_iterator first, const_iterator last, bool merge_objects=false)
updates a JSON object from another object, overwriting existing keys
static std::vector< std::uint8_t > to_bson(const basic_json &j)
create a BSON serialization of a given JSON value
const_reverse_iterator rbegin() const noexcept
returns an iterator to the reverse-beginning
void push_back(initializer_list_t init)
add an object to an object
detail::parser_callback_t< basic_json > parser_callback_t
per-element parser callback type
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
ValueType & get_to(ValueType &v) const
static void to_msgpack(const basic_json &j, detail::output_adapter< char > o)
create a MessagePack serialization of a given JSON value
iterator begin() noexcept
returns an iterator to the first element
void assert_invariant(bool check_parents=true) const noexcept
checks the class invariants
ReturnType value(const typename object_t::key_type &key, ValueType &&default_value) const
access specified object element with default value
ValueType get_impl(detail::priority_tag< 0 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), std::declval< ValueType & >())))
get a value (explicit)
json_value(string_t &&value)
constructor for rvalue strings
const_iterator cend() const noexcept
returns an iterator to one past the last element
constexpr const binary_t * get_impl_ptr(const binary_t *) const noexcept
get a pointer to the value (binary)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
const_reference at(const json_pointer &ptr) const
access specified element via JSON Pointer
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init)
explicitly create a binary array
basic_json(std::nullptr_t=nullptr) noexcept
create a null object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_cbor(InputType &&i, const bool strict=true, const bool allow_exceptions=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
create a JSON value from an input in CBOR format
constexpr const number_unsigned_t * get_impl_ptr(const number_unsigned_t *) const noexcept
get a pointer to the value (unsigned number)
constexpr const boolean_t * get_impl_ptr(const boolean_t *) const noexcept
get a pointer to the value (boolean)
basic_json flatten() const
return flattened JSON value
constexpr const array_t * get_impl_ptr(const array_t *) const noexcept
get a pointer to the value (array)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_ubjson(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in UBJSON format
json_value(number_unsigned_t v) noexcept
constructor for numbers (unsigned)
size_type erase(KeyType &&key)
remove element from a JSON object given a key
ArrayType< basic_json, AllocatorType< basic_json > > array_t
a type for an array
::nlohmann::detail::primitive_iterator_t primitive_iterator_t
json_value(const string_t &value)
constructor for strings
ObjectType< StringType, basic_json, default_object_comparator_t, AllocatorType< std::pair< const StringType, basic_json > > > object_t
a type for an object
const binary_t & get_binary() const
get a binary value
iterator insert(const_iterator pos, const_iterator first, const_iterator last)
inserts range of elements into array
void patch_inplace(const basic_json &json_patch)
applies a JSON patch in-place without copying the object
ReturnType value(KeyType &&key, ValueType &&default_value) const
access specified object element via JSON Pointer with default value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json diff(const basic_json &source, const basic_json &target, const std::string &path="")
creates a diff as a JSON patch
const_reference operator[](const json_pointer &ptr) const
access specified element via JSON Pointer
json_value(number_float_t v) noexcept
constructor for numbers (floating-point)
std::initializer_list< detail::json_ref< basic_json > > initializer_list_t
helper type for initializer lists of basic_json values
bool contains(KeyType &&key) const
check the existence of an element in a JSON object
static void to_cbor(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a CBOR serialization of a given JSON value
::nlohmann::detail::binary_reader< basic_json, InputType > binary_reader
static void to_bson(const basic_json &j, detail::output_adapter< char > o)
create a BSON serialization of a given JSON value
iterator find(const typename object_t::key_type &key)
find an element in a JSON object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(const typename binary_t::container_type &init)
explicitly create a binary array (without subtype)
BasicJsonType get_impl(detail::priority_tag< 2 >) const
get special-case overload
const_reference at(KeyType &&key) const
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json meta()
returns version information on the library
basic_json(size_type cnt, const basic_json &val)
construct an array with count copies of given value
const_iterator find(const typename object_t::key_type &key) const
find an element in a JSON object
static std::vector< std::uint8_t > to_cbor(const basic_json &j)
create a CBOR serialization of a given JSON value
IteratorType erase(IteratorType pos)
remove element given an iterator
iterator insert(const_iterator pos, const basic_json &val)
inserts element into array
NumberFloatType number_float_t
a type for a number (floating-point)
ValueType value(const typename object_t::key_type &key, const ValueType &default_value) const
access specified object element with default value
AllocatorType< basic_json > allocator_type
the allocator type
typename std::allocator_traits< allocator_type >::pointer pointer
the type of an element pointer
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
void merge_patch(const basic_json &apply_patch)
applies a JSON Merge Patch
ValueType & get_to(ValueType &v) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >(), v)))
get a value (explicit)
reference operator[](T *key)
reference at(size_type idx)
access specified array element with bounds checking
iterator find(KeyType &&key)
find an element in a JSON object
constexpr bool is_number_float() const noexcept
return whether value is a floating-point number
reverse_iterator rend() noexcept
returns an iterator to the reverse-end
static std::vector< std::uint8_t > to_ubjson(const basic_json &j, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
reference at(const json_pointer &ptr)
access specified element via JSON Pointer
BooleanType boolean_t
a type for a boolean
::nlohmann::detail::internal_iterator< BasicJsonType > internal_iterator
size_type erase_internal(KeyType &&key)
std::less< StringType > default_object_comparator_t
default object key comparator type The actual object key comparator type (object_comparator_t) may be...
reference operator+=(const typename object_t::value_type &val)
add an object to an object
const_iterator cbegin() const noexcept
returns a const iterator to the first element
constexpr const number_float_t * get_impl_ptr(const number_float_t *) const noexcept
get a pointer to the value (floating-point number)
reference operator[](typename object_t::key_type key)
access specified object element
string_t * get_impl_ptr(string_t *) noexcept
get a pointer to the value (string)
constexpr auto get_ptr() const noexcept -> decltype(std::declval< const basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
~basic_json() noexcept
destructor
json_value(binary_t &&value)
constructor for rvalue binary arrays (internal type)
const_reverse_iterator crend() const noexcept
returns a const reverse iterator to one before the first
basic_json(initializer_list_t init, bool type_deduction=true, value_t manual_type=value_t::array)
create a container (array or object) from an initializer list
json_value(const object_t &value)
constructor for objects
void swap(typename binary_t::container_type &other)
exchanges the values
binary_t & get_binary()
get a binary value
const_iterator begin() const noexcept
returns an iterator to the first element
constexpr bool is_number() const noexcept
return whether value is a number
number_unsigned_t * get_impl_ptr(number_unsigned_t *) noexcept
get a pointer to the value (unsigned number)
void insert(const_iterator first, const_iterator last)
inserts range of elements into object
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(InputType &&i, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
auto get() noexcept -> decltype(std::declval< basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
const_reference operator[](T *key) const
reference operator[](size_type idx)
access specified array element
basic_json(const JsonRef &ref)
JSONSerializer< T, SFINAE > json_serializer
basic_json & operator=(basic_json other) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value &&std::is_nothrow_move_assignable< json_base_class_t >::value)
copy assignment
static void to_ubjson(const basic_json &j, detail::output_adapter< char > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
Array get_to(T(&v)[N]) const noexcept(noexcept(JSONSerializer< Array >::from_json(std::declval< const basic_json_t & >(), v)))
NumberIntegerType number_integer_t
a type for a number (integer)
auto get_ptr() noexcept -> decltype(std::declval< basic_json_t & >().get_impl_ptr(std::declval< PointerType >()))
get a pointer value (implicit)
const_reference at(const typename object_t::key_type &key) const
access specified object element with bounds checking
binary_t * get_impl_ptr(binary_t *) noexcept
get a pointer to the value (binary)
constexpr bool is_binary() const noexcept
return whether value is a binary array
void swap(object_t &other)
exchanges the values
iterator set_parents(iterator it, typename iterator::difference_type count_set_parents)
constexpr auto get_impl(detail::priority_tag< 4 >) const noexcept -> decltype(std::declval< const basic_json_t & >().template get_ptr< PointerType >())
get a pointer value (explicit)
basic_json unflatten() const
unflatten a previously flattened JSON value
iterator insert(const_iterator pos, initializer_list_t ilist)
inserts elements from initializer list into array
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json binary(typename binary_t::container_type &&init, typename binary_t::subtype_type subtype)
explicitly create a binary array (with subtype)
iteration_proxy< iterator > items() noexcept
helper to access iterator member functions in range-based for
bool empty() const noexcept
checks whether the container is empty.
void swap(array_t &other)
exchanges the values
void erase(const size_type idx)
remove element from a JSON array given an index
reference operator+=(basic_json &&val)
add an object to an array
bool contains(const json_pointer &ptr) const
check the existence of an element in a JSON object given a JSON pointer
ValueType get_impl(detail::priority_tag< 1 >) const noexcept(noexcept(JSONSerializer< ValueType >::from_json(std::declval< const basic_json_t & >())))
get a value (explicit); special case
constexpr value_t type() const noexcept
return the type of the JSON value (explicit)
reference emplace_back(Args &&... args)
add an object to an array
ValueType value(const json_pointer &ptr, const ValueType &default_value) const
access specified object element via JSON Pointer with default value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json array(initializer_list_t init={})
explicitly create an array from an initializer list
StringType string_t
a type for a string
void push_back(const basic_json &val)
add an object to an array
ValueType value(KeyType &&key, const ValueType &default_value) const
access specified object element with default value
reference at(const typename object_t::key_type &key)
access specified object element with bounds checking
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_bjdata(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in BJData format
json_value m_value
the value of the current element
const_reverse_iterator crbegin() const noexcept
returns a const reverse iterator to the last element
json_sax< basic_json > json_sax_t
SAX interface type, see nlohmann::json_sax.
constexpr bool is_boolean() const noexcept
return whether value is a boolean
size_type count(const typename object_t::key_type &key) const
returns the number of occurrences of a key in a JSON object
reference front()
access the first element
constexpr bool is_primitive() const noexcept
return whether type is primitive
constexpr bool is_null() const noexcept
return whether value is null
void clear() noexcept
clears the contents
constexpr const object_t * get_impl_ptr(const object_t *) const noexcept
get a pointer to the value (object)
json_value(value_t t)
constructor for empty values of a given type
static ::nlohmann::detail::parser< basic_json, InputAdapterType > parser(InputAdapterType adapter, detail::parser_callback_t< basic_json >cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
static void to_ubjson(const basic_json &j, detail::output_adapter< std::uint8_t > o, const bool use_size=false, const bool use_type=false)
create a UBJSON serialization of a given JSON value
json_value()=default
default constructor (for null values)
basic_json(basic_json &&other) noexcept
move constructor
array_t * array
array (stored with pointer to save storage)
iter_impl< basic_json > iterator
an iterator for a basic_json container
basic_json(const value_t v)
create an empty value with a given type
const_reference operator[](size_type idx) const
access specified array element
std::ptrdiff_t difference_type
a type to represent differences between iterators
iterator insert(const_iterator pos, basic_json &&val)
inserts element into array
const_reverse_iterator rend() const noexcept
returns an iterator to the reverse-end
NumberUnsignedType number_unsigned_t
a type for a number (unsigned)
friend std::istream & operator>>(std::istream &i, basic_json &j)
deserialize from stream
static std::vector< std::uint8_t > to_msgpack(const basic_json &j)
create a MessagePack serialization of a given JSON value
void swap(string_t &other)
exchanges the values
basic_json(const BasicJsonType &val)
create a JSON value from an existing one
NLOHMANN_BASIC_JSON_TPL basic_json_t
workaround type for MSVC
boolean_t * get_impl_ptr(boolean_t *) noexcept
get a pointer to the value (boolean)
::nlohmann::detail::binary_writer< basic_json, CharType > binary_writer
json_reverse_iterator< typename basic_json::iterator > reverse_iterator
a reverse iterator for a basic_json container
friend void swap(reference left, reference right) noexcept(std::is_nothrow_move_constructible< value_t >::value &&std::is_nothrow_move_assignable< value_t >::value &&std::is_nothrow_move_constructible< json_value >::value &&std::is_nothrow_move_assignable< json_value >::value)
exchanges the values
json_value(const binary_t &value)
constructor for binary arrays (internal type)
const_reference at(size_type idx) const
access specified array element with bounds checking
detail::actual_object_comparator_t< basic_json > object_comparator_t
object key comparator type
basic_json(const basic_json &other)
copy constructor
void push_back(const typename object_t::value_type &val)
add an object to an object
std::pair< iterator, bool > emplace(Args &&... args)
add an object to an object if key does not exist
static void to_cbor(const basic_json &j, detail::output_adapter< char > o)
create a CBOR serialization of a given JSON value
constexpr bool is_object() const noexcept
return whether value is an object
static void to_msgpack(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a MessagePack serialization of a given JSON value
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json from_msgpack(IteratorType first, IteratorType last, const bool strict=true, const bool allow_exceptions=true)
create a JSON value from an input in MessagePack format
iterator insert_iterator(const_iterator pos, Args &&... args)
basic_json(InputIT first, InputIT last)
construct a JSON container given an iterator range
bool contains(const typename object_t::key_type &key) const
check the existence of an element in a JSON object
static void to_bson(const basic_json &j, detail::output_adapter< std::uint8_t > o)
create a BSON serialization of a given JSON value
const_iterator find(KeyType &&key) const
find an element in a JSON object
json_value(const typename binary_t::container_type &value)
constructor for binary arrays
::nlohmann::json_pointer< StringType > json_pointer
JSON Pointer, see nlohmann::json_pointer.
an internal type for a backed binary type
bool operator!=(const byte_container_with_subtype &rhs) const
byte_container_with_subtype() noexcept(noexcept(container_type()))
std::uint64_t subtype_type
bool operator==(const byte_container_with_subtype &rhs) const
BinaryType container_type
byte_container_with_subtype(container_type &&b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
byte_container_with_subtype(container_type &&b) noexcept(noexcept(container_type(std::move(b))))
constexpr subtype_type subtype() const noexcept
return the binary subtype
byte_container_with_subtype(const container_type &b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
constexpr bool has_subtype() const noexcept
return whether the value has a subtype
byte_container_with_subtype(const container_type &b) noexcept(noexcept(container_type(b)))
void set_subtype(subtype_type subtype_) noexcept
sets the binary subtype
void clear_subtype() noexcept
clears the binary subtype
deserialization of CBOR, MessagePack, and UBJSON values
bool get_string(const input_format_t format, const NumberType len, string_t &result)
create a string by reading characters from the input
bool get_ubjson_size_type(std::pair< std::size_t, char_int_type > &result, bool inside_ndarray=false)
determine the type and size for a container
binary_reader(const binary_reader &)=delete
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
typename BasicJsonType::string_t string_t
std::pair< char_int_type, string_t > bjd_type
typename std::char_traits< char_type >::int_type char_int_type
bool parse_bson_element_list(const bool is_array)
Read a BSON element list (as specified in the BSON-spec)
typename InputAdapterType::char_type char_type
bool parse_msgpack_internal()
std::string get_token_string() const
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool get_msgpack_string(string_t &result)
reads a MessagePack string
std::string exception_message(const input_format_t format, const std::string &detail, const std::string &context) const
bool get_ubjson_high_precision_number()
bool get_binary(const input_format_t format, const NumberType len, binary_t &result)
create a byte array by reading bytes from the input
binary_reader(binary_reader &&)=default
char_int_type get_ignore_noop()
bool get_ubjson_value(const char_int_type prefix)
bool get_ubjson_ndarray_size(std::vector< size_t > &dim)
bool parse_bson_element_internal(const char_int_type element_type, const std::size_t element_type_parse_position)
Read a BSON document element of the given element_type.
bool get_msgpack_object(const std::size_t len)
binary_reader(InputAdapterType &&adapter, const input_format_t format=input_format_t::json) noexcept
create a binary reader
typename BasicJsonType::binary_t binary_t
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
binary_reader & operator=(const binary_reader &)=delete
bool get_cbor_object(const std::size_t len, const cbor_tag_handler_t tag_handler)
bool get_cbor_binary(binary_t &result)
reads a CBOR byte array
bool get_number(const input_format_t format, NumberType &result)
typename BasicJsonType::number_integer_t number_integer_t
bool get_bson_cstr(string_t &result)
Parses a C-style string from the BSON input.
bool sax_parse(const input_format_t format, json_sax_t *sax_, const bool strict=true, const cbor_tag_handler_t tag_handler=cbor_tag_handler_t::error)
bool get_cbor_array(const std::size_t len, const cbor_tag_handler_t tag_handler)
bool get_msgpack_array(const std::size_t len)
char_int_type get()
get next character from the input
typename BasicJsonType::number_float_t number_float_t
bool get_msgpack_binary(binary_t &result)
reads a MessagePack byte array
bool parse_ubjson_internal(const bool get_char=true)
bool get_ubjson_size_value(std::size_t &result, bool &is_ndarray, char_int_type prefix=0)
bool parse_cbor_internal(const bool get_char, const cbor_tag_handler_t tag_handler)
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
bool get_ubjson_string(string_t &result, const bool get_char=true)
reads a UBJSON string
bool get_cbor_string(string_t &result)
reads a CBOR string
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
binary_reader & operator=(binary_reader &&)=default
void write_bson_binary(const string_t &name, const binary_t &value)
Writes a BSON element with key name and binary value value.
void write_bson_boolean(const string_t &name, const bool value)
Writes a BSON element with key name and boolean value value.
void write_bson(const BasicJsonType &j)
typename BasicJsonType::binary_t binary_t
void write_bson_integer(const string_t &name, const std::int64_t value)
Writes a BSON element with key name and integer value.
typename BasicJsonType::string_t string_t
static constexpr CharType to_char_type(std::uint8_t x) noexcept
static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept
void write_bson_array(const string_t &name, const typename BasicJsonType::array_t &value)
Writes a BSON element with key name and array value.
bool write_bjdata_ndarray(const typename BasicJsonType::object_t &value, const bool use_count, const bool use_type)
static CharType to_char_type(std::uint8_t x) noexcept
static constexpr CharType get_cbor_float_prefix(double)
void write_bson_string(const string_t &name, const string_t &value)
Writes a BSON element with key name and string value value.
binary_writer(output_adapter_t< CharType > adapter)
create a binary writer
static constexpr CharType get_ubjson_float_prefix(double)
void write_number_with_ubjson_prefix(const NumberType n, const bool add_prefix, const bool use_bjdata)
static constexpr CharType get_msgpack_float_prefix(double)
void write_bson_element(const string_t &name, const BasicJsonType &j)
Serializes the JSON value j to BSON and associates it with the key name.
static constexpr CharType to_char_type(InputCharType x) noexcept
void write_bson_object(const typename BasicJsonType::object_t &value)
void write_ubjson(const BasicJsonType &j, const bool use_count, const bool use_type, const bool add_prefix=true, const bool use_bjdata=false)
void write_bson_double(const string_t &name, const double value)
Writes a BSON element with key name and double value value.
static std::size_t calc_bson_string_size(const string_t &value)
void write_number(const NumberType n, const bool OutputIsLittleEndian=false)
static std::size_t calc_bson_entry_header_size(const string_t &name, const BasicJsonType &j)
void write_bson_null(const string_t &name)
Writes a BSON element with key name and null value.
typename BasicJsonType::number_float_t number_float_t
CharType ubjson_prefix(const BasicJsonType &j, const bool use_bjdata) const noexcept
determine the type prefix of container values
void write_bson_unsigned(const string_t &name, const BasicJsonType &j)
Writes a BSON element with key name and unsigned value.
static constexpr CharType get_ubjson_float_prefix(float)
static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t &value)
static std::size_t calc_bson_element_size(const string_t &name, const BasicJsonType &j)
Calculates the size necessary to serialize the JSON value j with its name.
void write_msgpack(const BasicJsonType &j)
static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t &value)
Calculates the size of the BSON serialization of the given JSON-object j.
void write_compact_float(const number_float_t n, detail::input_format_t format)
void write_cbor(const BasicJsonType &j)
static constexpr CharType get_cbor_float_prefix(float)
void write_bson_entry_header(const string_t &name, const std::uint8_t element_type)
Writes the given element_type and name to the output adapter.
void write_bson_object_entry(const string_t &name, const typename BasicJsonType::object_t &value)
Writes a BSON element with key name and object value.
static constexpr CharType get_msgpack_float_prefix(float)
static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t &value)
static std::size_t calc_bson_integer_size(const std::int64_t value)
general exception of the basic_json class
const int id
the id of the exception
static std::string diagnostics(std::nullptr_t)
std::runtime_error m
an exception object as storage for error messages
static std::string name(const std::string &ename, int id_)
const char * what() const noexcept override
returns the explanatory string
static std::string diagnostics(const BasicJsonType *leaf_element)
exception indicating errors with iterators
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
iter_impl operator+(difference_type i) const
add to iterator
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
bool operator<(const iter_impl &other) const
comparison: smaller
bool operator<=(const iter_impl &other) const
comparison: less than or equal
iter_impl & operator-=(difference_type i)
subtract from iterator
iter_impl & operator--()
pre-decrement (–it)
const object_t::key_type & key() const
return the key of an object iterator
bool operator==(const IterImpl &other) const
comparison: equal
iter_impl operator++(int) &
post-increment (it++)
iter_impl & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
iter_impl< typename std::conditional< std::is_const< BasicJsonType >::value, typename std::remove_const< BasicJsonType >::type, const BasicJsonType >::type > other_iter_impl
the iterator with BasicJsonType of different const-ness
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
pointer operator->() const
dereference the iterator
difference_type operator-(const iter_impl &other) const
return difference
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
reference value() const
return the value of an iterator
bool operator>(const iter_impl &other) const
comparison: greater than
typename BasicJsonType::array_t array_t
typename BasicJsonType::object_t object_t
iter_impl & operator++()
pre-increment (++it)
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
reference operator*() const
return a reference to the value pointed to by the iterator
iter_impl operator-(difference_type i) const
subtract from iterator
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
bool operator!=(const IterImpl &other) const
comparison: not equal
iter_impl operator--(int) &
post-decrement (it–)
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
void set_end() noexcept
set the iterator past the last value
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
iteration_proxy_value operator++(int) &
iteration_proxy_value(iteration_proxy_value const &)=default
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
std::ptrdiff_t difference_type
string_type empty_str
an empty string (to return a reference for primitive values)
iteration_proxy_value(IteratorType it, std::size_t array_index_=0) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_default_constructible< string_type >::value)
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
iteration_proxy_value()=default
std::size_t array_index_last
last stringified array index
std::size_t array_index
an index for arrays (used to create key names)
iteration_proxy_value(iteration_proxy_value &&) noexcept(std::is_nothrow_move_constructible< IteratorType >::value &&std::is_nothrow_move_constructible< string_type >::value)=default
IteratorType::reference value() const
return value of the iterator
const string_type & key() const
return key of the iterator
iteration_proxy_value & operator=(iteration_proxy_value const &)=default
std::input_iterator_tag iterator_category
string_type array_index_str
a string representation of the array index
typename std::remove_cv< typename std::remove_reference< decltype(std::declval< IteratorType >().key()) >::type >::type string_type
IteratorType anchor
the iterator
proxy class for the items() function
IteratorType::pointer container
the container to iterate
iteration_proxy_value< IteratorType > end() const noexcept
return iterator end (needed for range-based for)
iteration_proxy(iteration_proxy const &)=default
iteration_proxy()=default
iteration_proxy(iteration_proxy &&) noexcept=default
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
iteration_proxy & operator=(iteration_proxy const &)=default
json_ref(json_ref &&) noexcept=default
json_ref(const value_type &value)
json_ref(value_type &&value)
value_type const & operator*() const
value_type const * operator->() const
json_ref(std::initializer_list< json_ref > init)
json_ref(Args &&... args)
a template for a reverse iterator class
json_reverse_iterator operator++(int) &
post-increment (it++)
json_reverse_iterator operator--(int) &
post-decrement (it–)
json_reverse_iterator & operator++()
pre-increment (++it)
std::ptrdiff_t difference_type
json_reverse_iterator & operator+=(difference_type i)
add to iterator
reference operator[](difference_type n) const
access to successor
auto key() const -> decltype(std::declval< Base >().key())
return the key of an object iterator
difference_type operator-(const json_reverse_iterator &other) const
return difference
typename Base::reference reference
the reference type for the pointed-to element
reference value() const
return the value of an iterator
json_reverse_iterator(const base_iterator &it) noexcept
create reverse iterator from base class
json_reverse_iterator & operator--()
pre-decrement (–it)
std::reverse_iterator< Base > base_iterator
shortcut to the reverse iterator adapter
json_reverse_iterator operator-(difference_type i) const
subtract from iterator
json_reverse_iterator(const typename base_iterator::iterator_type &it) noexcept
create reverse iterator from iterator
json_reverse_iterator operator+(difference_type i) const
add to iterator
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool start_object(std::size_t=static_cast< std::size_t >(-1))
bool number_integer(number_integer_t)
bool start_array(std::size_t=static_cast< std::size_t >(-1))
bool number_unsigned(number_unsigned_t)
typename BasicJsonType::binary_t binary_t
bool number_float(number_float_t, const string_t &)
bool parse_error(std::size_t, const std::string &, const detail::exception &)
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::string_t string_t
bool parse_error(std::size_t, const std::string &, const Exception &ex)
typename BasicJsonType::string_t string_t
bool number_float(number_float_t val, const string_t &)
constexpr bool is_errored() const
bool string(string_t &val)
json_sax_dom_callback_parser & operator=(const json_sax_dom_callback_parser &)=delete
json_sax_dom_callback_parser(const json_sax_dom_callback_parser &)=delete
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::binary_t binary_t
bool start_object(std::size_t len)
bool start_array(std::size_t len)
typename BasicJsonType::number_integer_t number_integer_t
json_sax_dom_callback_parser(json_sax_dom_callback_parser &&)=default
std::pair< bool, BasicJsonType * > handle_value(Value &&v, const bool skip_callback=false)
~json_sax_dom_callback_parser()=default
typename BasicJsonType::parse_event_t parse_event_t
typename BasicJsonType::parser_callback_t parser_callback_t
bool number_unsigned(number_unsigned_t val)
json_sax_dom_callback_parser & operator=(json_sax_dom_callback_parser &&)=default
json_sax_dom_callback_parser(BasicJsonType &r, const parser_callback_t cb, const bool allow_exceptions_=true)
typename BasicJsonType::number_float_t number_float_t
bool number_integer(number_integer_t val)
bool binary(binary_t &val)
SAX implementation to create a JSON value from SAX events.
json_sax_dom_parser(const json_sax_dom_parser &)=delete
json_sax_dom_parser & operator=(json_sax_dom_parser &&)=default
bool string(string_t &val)
json_sax_dom_parser(BasicJsonType &r, const bool allow_exceptions_=true)
bool parse_error(std::size_t, const std::string &, const Exception &ex)
~json_sax_dom_parser()=default
typename BasicJsonType::string_t string_t
bool start_object(std::size_t len)
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool number_unsigned(number_unsigned_t val)
bool number_integer(number_integer_t val)
JSON_HEDLEY_RETURNS_NON_NULL BasicJsonType * handle_value(Value &&v)
typename BasicJsonType::number_integer_t number_integer_t
json_sax_dom_parser & operator=(const json_sax_dom_parser &)=delete
bool binary(binary_t &val)
json_sax_dom_parser(json_sax_dom_parser &&)=default
bool number_float(number_float_t val, const string_t &)
constexpr bool is_errored() const
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::number_float_t number_float_t
bool start_array(std::size_t len)
JSON_HEDLEY_RETURNS_NON_NULL static JSON_HEDLEY_CONST const char * token_type_name(const token_type t) noexcept
return name of values of type token_type (only used for errors)
token_type
token types for the parser
void reset() noexcept
reset token_buffer; current character is beginning of token
bool skip_bom()
skip the UTF-8 byte order mark
int get_codepoint()
get codepoint from 4 hex characters following \u
token_type scan_string()
scan a string literal
lexer(InputAdapterType &&adapter, bool ignore_comments_=false) noexcept
JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message() const noexcept
return syntax error message
std::string get_token_string() const
typename BasicJsonType::number_float_t number_float_t
constexpr number_integer_t get_number_integer() const noexcept
return integer value
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
bool next_byte_in_range(std::initializer_list< char_int_type > ranges)
check if the next byte(s) are inside a given range
constexpr position_t get_position() const noexcept
return position of last read token
typename BasicJsonType::number_integer_t number_integer_t
constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
bool scan_comment()
scan a comment
typename lexer_base< BasicJsonType >::token_type token_type
lexer & operator=(lexer &&)=default
lexer(const lexer &)=delete
typename InputAdapterType::char_type char_type
lexer & operator=(lexer &)=delete
token_type scan_number()
scan a number literal
typename std::char_traits< char_type >::int_type char_int_type
string_t & get_string()
return current string value (implicitly resets the token; useful only once)
void add(char_int_type c)
add a character to token_buffer
void unget()
unget current character (read it again on next get)
constexpr number_float_t get_number_float() const noexcept
return floating-point value
static JSON_HEDLEY_PURE char get_decimal_point() noexcept
return the locale-dependent decimal point
exception indicating other library errors
static other_error create(int id_, const std::string &what_arg, BasicJsonContext context)
exception indicating access out of the defined range
static out_of_range create(int id_, const std::string &what_arg, BasicJsonContext context)
output_adapter(StringType &s)
output_adapter(std::basic_ostream< CharType > &s)
output_adapter(std::vector< CharType, AllocatorType > &vec)
output adapter for output streams
output_stream_adapter(std::basic_ostream< CharType > &s) noexcept
void write_character(CharType c) override
output adapter for basic_string
void write_character(CharType c) override
output_string_adapter(StringType &s) noexcept
output adapter for byte vectors
output_vector_adapter(std::vector< CharType, AllocatorType > &vec) noexcept
void write_character(CharType c) override
exception indicating a parse error
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, BasicJsonContext context)
create a parse error exception
static std::string position_string(const position_t &pos)
static parse_error create(int id_, std::size_t byte_, const std::string &what_arg, BasicJsonContext context)
const std::size_t byte
byte index of the parse error
parse_error(int id_, std::size_t byte_, const char *what_arg)
std::string exception_message(const token_type expected, const std::string &context)
parser(InputAdapterType &&adapter, const parser_callback_t< BasicJsonType > cb=nullptr, const bool allow_exceptions_=true, const bool skip_comments=false)
a parser reading from an input adapter
typename lexer_t::token_type token_type
void parse(const bool strict, BasicJsonType &result)
public parser interface
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
lexer< BasicJsonType, InputAdapterType > lexer_t
bool accept(const bool strict=true)
public accept interface
typename BasicJsonType::number_float_t number_float_t
token_type get_token()
get next token from lexer
primitive_iterator_t & operator++() noexcept
primitive_iterator_t & operator-=(difference_type n) noexcept
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
primitive_iterator_t & operator--() noexcept
void set_end() noexcept
set iterator to a defined past the end
friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr bool is_end() const noexcept
return whether the iterator is at end
primitive_iterator_t operator++(int) &noexcept
primitive_iterator_t & operator+=(difference_type n) noexcept
friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
constexpr difference_type get_value() const noexcept
friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept
primitive_iterator_t operator+(difference_type n) noexcept
void set_begin() noexcept
set iterator to a defined beginning
primitive_iterator_t operator--(int) &noexcept
std::ptrdiff_t difference_type
typename BasicJsonType::binary_t::value_type binary_char_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
serializer(output_adapter_t< char > s, const char ichar, error_handler_t error_handler_=error_handler_t::strict)
serializer & operator=(const serializer &)=delete
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_float_t number_float_t
serializer & operator=(serializer &&)=delete
typename BasicJsonType::string_t string_t
void dump(const BasicJsonType &val, const bool pretty_print, const bool ensure_ascii, const unsigned int indent_step, const unsigned int current_indent=0)
internal implementation of the serialization function
serializer(const serializer &)=delete
serializer(serializer &&)=delete
exception indicating executing a member function with a wrong type
static type_error create(int id_, const std::string &what_arg, BasicJsonContext context)
JSON Pointer defines a string syntax for identifying a specific value within a JSON document.
BasicJsonType & get_checked(BasicJsonType *ptr) const
json_pointer< string_t > convert() const &
friend json_pointer operator/(const json_pointer &lhs, string_t token)
create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
static BasicJsonType::size_type array_index(const string_t &s)
typename string_t_helper< RefStringType >::type string_t
friend json_pointer operator/(const json_pointer &lhs, std::size_t array_idx)
create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
json_pointer(const string_t &s="")
create JSON pointer
static std::vector< string_t > split(const string_t &reference_string)
split the string input to reference tokens
bool empty() const noexcept
return whether pointer points to the root document
BasicJsonType & get_and_create(BasicJsonType &j) const
create and return a reference to the pointed to value
void pop_back()
remove last reference token
string_t to_string() const
return a string representation of the JSON pointer
json_pointer & operator/=(std::size_t array_idx)
append an array index at the end of this JSON pointer
void push_back(string_t &&token)
append an unescaped token at the end of the reference pointer
json_pointer< string_t > convert() &&
static void flatten(const string_t &reference_string, const BasicJsonType &value, BasicJsonType &result)
json_pointer & operator/=(const json_pointer &ptr)
append another JSON pointer at the end of this JSON pointer
friend json_pointer operator/(const json_pointer &lhs, const json_pointer &rhs)
create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
BasicJsonType & get_unchecked(BasicJsonType *ptr) const
return a reference to the pointed to value
json_pointer parent_pointer() const
returns the parent of this JSON pointer
static BasicJsonType unflatten(const BasicJsonType &value)
json_pointer & operator/=(string_t token)
append an unescaped reference token at the end of this JSON pointer
const string_t & back() const
return last reference token
friend std::ostream & operator<<(std::ostream &o, const json_pointer &ptr)
write string representation of the JSON pointer to stream
const BasicJsonType & get_unchecked(const BasicJsonType *ptr) const
return a const reference to the pointed to value
void push_back(const string_t &token)
append an unescaped token at the end of the reference pointer
const BasicJsonType & get_checked(const BasicJsonType *ptr) const
bool contains(const BasicJsonType *ptr) const
result reference_tokens
the reference tokens
decltype( get< N >(std::declval< ::nlohmann::detail::iteration_proxy_value< IteratorType > >())) type
JSON_INLINE_VARIABLE constexpr const auto & from_json
JSON_INLINE_VARIABLE constexpr const auto & to_json
int find_largest_pow10(const std::uint32_t n, std::uint32_t &pow10)
cached_power get_cached_power_for_binary_exponent(int e)
Target reinterpret_bits(const Source source)
boundaries compute_boundaries(FloatType value)
void grisu2_round(char *buf, int len, std::uint64_t dist, std::uint64_t delta, std::uint64_t rest, std::uint64_t ten_k)
void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus, diyfp v, diyfp m_plus)
void grisu2_digit_gen(char *buffer, int &length, int &decimal_exponent, diyfp M_minus, diyfp w, diyfp M_plus)
JSON_HEDLEY_RETURNS_NON_NULL char * append_exponent(char *buf, int e)
appends a decimal representation of e to buf
constexpr bool is_transparent()
constexpr bool is_c_string()
detail namespace with internal helper functions
make_integer_sequence< size_t, N > make_index_sequence
decltype(std::declval< StringType & >().append(std::declval< Arg && >())) string_can_append
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
input_format_t
the supported input formats
typename detector< nonesuch, void, Op, Args... >::type detected_t
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
static void unescape(StringType &s)
string unescaping as described in RFC 6901 (Sect. 4)
decltype(T::to_json(std::declval< Args >()...)) to_json_function
detector< Default, void, Op, Args... > detected_or
decltype(std::declval< T & >().binary(std::declval< Binary & >())) binary_function_t
is_detected< string_can_append_data, StringType, Arg > detect_string_can_append_data
decltype(std::declval< T & >().end_object()) end_object_function_t
OutStringType concat(Args &&... args)
typename T::value_type value_type_t
constexpr std::array< T, sizeof...(Args)> make_array(Args &&... args)
decltype(std::declval< T & >().boolean(std::declval< bool >())) boolean_function_t
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
is_detected< string_can_append, StringType, Arg > detect_string_can_append
typename std::enable_if< B, T >::type enable_if_t
@ value
the parser finished reading a JSON value
@ key
the parser read a key of a value in an object
@ array_end
the parser read ] and finished processing a JSON array
@ array_start
the parser read [ and started to process a JSON array
@ object_start
the parser read { and started to process a JSON object
@ object_end
the parser read } and finished processing a JSON object
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
typename T::pointer pointer_t
std::pair< A1, A2 > from_json_tuple_impl(BasicJsonType &&j, identity_tag< std::pair< A1, A2 > >, priority_tag< 0 >)
void from_json_array_impl(const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
typename utility_internal::Gen< T, N >::type make_integer_sequence
conjunction< std::is_integral< Types >... > all_integral
std::shared_ptr< output_adapter_protocol< CharType > > output_adapter_t
a type to simplify interfaces
typename detected_or< Default, Op, Args... >::type detected_or_t
decltype(std::declval< T & >().key(std::declval< String & >())) key_function_t
decltype(std::declval< T & >().null()) null_function_t
T conditional_static_cast(U value)
typename T::difference_type difference_type_t
conjunction< std::is_unsigned< Types >... > all_unsigned
decltype(std::declval< T & >().start_object(std::declval< std::size_t >())) start_object_function_t
decltype(std::declval< T & >().number_float( std::declval< Float >(), std::declval< const String & >())) number_float_function_t
void replace_substring(StringType &s, const StringType &f, const StringType &t)
replace all occurrences of a substring by another string
decltype(std::declval< T & >().start_array(std::declval< std::size_t >())) start_array_function_t
is_detected< string_can_append_iter, StringType, Arg > detect_string_can_append_iter
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
cbor_tag_handler_t
how to treat CBOR tags
@ store
store tags as binary type
@ error
throw a parse_error exception in case of a tag
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
decltype(input_adapter(std::declval< const char * >(), std::declval< const char * >())) contiguous_bytes_input_adapter
make_index_sequence< sizeof...(Ts)> index_sequence_for
void concat_into(OutStringType &)
constexpr bool value_in_range_of(T val)
value_t
the JSON type enumeration
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
decltype(T::from_json(std::declval< Args >()...)) from_json_function
conjunction< std::is_signed< Types >... > all_signed
std::array< T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType &&j, identity_tag< std::array< T, sizeof...(Idx)> >, index_sequence< Idx... >)
static bool little_endianness(int num=1) noexcept
determine system byte order
std::size_t hash(const BasicJsonType &j)
hash a JSON value
decltype(std::declval< T & >().number_integer(std::declval< Integer >())) number_integer_function_t
typename make_void< Ts... >::type void_t
std::size_t combine(std::size_t seed, std::size_t h) noexcept
decltype(std::declval< T & >().parse_error( std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >())) parse_error_function_t
bool operator<(const value_t lhs, const value_t rhs) noexcept
comparison operator for JSON types
iterator_input_adapter_factory< IteratorType >::adapter_type input_adapter(IteratorType first, IteratorType last)
enable_if_t< is_range< R >::value, result_of_begin< decltype(std::declval< R & >())> > iterator_t
typename T::iterator_category iterator_category_t
typename std::conditional< std::is_same< T, void >::value, json_default_base, T >::type json_base_class
is_c_string< uncvref_t< T > > is_c_string_uncvref
error_handler_t
how to treat decoding errors
@ strict
throw a type_error exception in case of invalid UTF-8
@ replace
replace invalid UTF-8 sequences with U+FFFD
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
std::size_t concat_length()
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
void from_json(const BasicJsonType &j, typename std::nullptr_t &n)
typename T::key_compare detect_key_compare
void to_json(BasicJsonType &j, T b) noexcept
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
integer_sequence< size_t, Ints... > index_sequence
std::is_convertible< detected_t< Op, Args... >, To > is_detected_convertible
is_specialization_of<::nlohmann::json_pointer, uncvref_t< T > > is_json_pointer
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().begin(), std::declval< const Arg & >().end())) string_can_append_iter
decltype(std::declval< T & >().end_array()) end_array_function_t
std::tuple< Args... > from_json_tuple_impl_base(BasicJsonType &&j, index_sequence< Idx... >)
decltype(std::declval< StringType & >().append(std::declval< const Arg & >().data(), std::declval< const Arg & >().size())) string_can_append_data
typename T::key_type key_type_t
typename T::reference reference_t
typename T::is_transparent detect_is_transparent
is_detected< string_can_append_op, StringType, Arg > detect_string_can_append_op
typename T::mapped_type mapped_type_t
decltype(std::declval< StringType & >()+=std::declval< Arg && >()) string_can_append_op
StringType escape(StringType s)
string escaping as described in RFC 6901 (Sect. 4)
void int_to_string(string_type &target, std::size_t value)
decltype(std::declval< T & >().string(std::declval< String & >())) string_function_t
decltype(std::declval< T >().template get< U >()) get_template_function
decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >())) number_unsigned_function_t
std::function< bool(int, parse_event_t, BasicJsonType &)> parser_callback_t
DOCTEST_INTERFACE bool operator>=(const String &lhs, const String &rhs)
DOCTEST_INTERFACE bool operator>(const String &lhs, const String &rhs)
decltype(sizeof(void *)) size_t
decltype(nullptr) nullptr_t
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
namespace for Niels Lohmann
static auto to_json(BasicJsonType &j, TargetType &&val) noexcept(noexcept(::nlohmann::to_json(j, std::forward< TargetType >(val)))) -> decltype(::nlohmann::to_json(j, std::forward< TargetType >(val)), void())
convert any value type to a JSON value
static auto from_json(BasicJsonType &&j) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), detail::identity_tag< TargetType > {}))
convert a JSON value to any value type
static auto from_json(BasicJsonType &&j, TargetType &val) noexcept(noexcept(::nlohmann::from_json(std::forward< BasicJsonType >(j), val))) -> decltype(::nlohmann::from_json(std::forward< BasicJsonType >(j), val), void())
convert a JSON value to any value type
typename BasicJsonType::object_t object_t
typename BasicJsonType::default_object_comparator_t object_comparator_t
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
static diyfp mul(const diyfp &x, const diyfp &y) noexcept
returns x * y
static diyfp normalize_to(const diyfp &x, const int target_exponent) noexcept
normalize x such that the result has the exponent E
static diyfp normalize(diyfp x) noexcept
normalize x such that the significand is >= 2^(q-1)
static diyfp sub(const diyfp &x, const diyfp &y) noexcept
returns x - y
constexpr diyfp(std::uint64_t f_, int e_) noexcept
static void construct(BasicJsonType &j, const std::vector< bool > &arr)
static void construct(BasicJsonType &j, typename BasicJsonType::array_t &&arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::array_t &arr)
static void construct(BasicJsonType &j, const CompatibleArrayType &arr)
static void construct(BasicJsonType &j, const std::valarray< T > &arr)
static void construct(BasicJsonType &j, const typename BasicJsonType::binary_t &b)
static void construct(BasicJsonType &j, typename BasicJsonType::binary_t &&b)
static void construct(BasicJsonType &j, typename BasicJsonType::boolean_t b) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_float_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_integer_t val) noexcept
static void construct(BasicJsonType &j, typename BasicJsonType::number_unsigned_t val) noexcept
static void construct(BasicJsonType &j, const typename BasicJsonType::object_t &obj)
static void construct(BasicJsonType &j, const CompatibleObjectType &obj)
static void construct(BasicJsonType &j, typename BasicJsonType::object_t &&obj)
static void construct(BasicJsonType &j, typename BasicJsonType::string_t &&s)
static void construct(BasicJsonType &j, const CompatibleStringType &str)
static void construct(BasicJsonType &j, const typename BasicJsonType::string_t &s)
auto operator()(const BasicJsonType &j, T &&val) const noexcept(noexcept(from_json(j, std::forward< T >(val)))) -> decltype(from_json(j, std::forward< T >(val)))
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
typename BasicJsonType::template json_serializer< T, void > serializer
static constexpr std::size_t size() noexcept
std::numeric_limits< RealIntegerType > RealLimits
std::numeric_limits< CompatibleNumberIntegerType > CompatibleLimits
typename BasicJsonType::object_t object_t
static constexpr auto value
detail::is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< !std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value &&!is_compatible_string_type< BasicJsonType, ConstructibleArrayType >::value &&is_default_constructible< ConstructibleArrayType >::value &&(std::is_move_assignable< ConstructibleArrayType >::value||std::is_copy_assignable< ConstructibleArrayType >::value)&&is_detected< iterator_t, ConstructibleArrayType >::value &&is_iterator_traits< iterator_traits< detected_t< iterator_t, ConstructibleArrayType > > >::value &&is_detected< range_value_t, ConstructibleArrayType >::value &&!std::is_same< ConstructibleArrayType, detected_t< range_value_t, ConstructibleArrayType > >::value &&is_complete_type< detected_t< range_value_t, ConstructibleArrayType > >::value > >::value_type range_value_t< ConstructibleArrayType > value_type
typename BasicJsonType::object_t object_t
static constexpr auto value
ConstructibleStringType laundered_type
static constexpr bool value
typename std::iterator_traits< T >::value_type value_type
iterator_traits< T > traits
static one test(decltype(&C::capacity))
detected_t< result_of_end, t_ref > sentinel
detected_t< result_of_begin, t_ref > iterator
static constexpr bool value
static constexpr auto is_iterator_begin
typename std::add_lvalue_reference< T >::type t_ref
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::exception exception_t
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::binary_t binary_t
typename BasicJsonType::exception exception_t
typename BasicJsonType::number_float_t number_float_t
typename BasicJsonType::string_t string_t
typename BasicJsonType::number_unsigned_t number_unsigned_t
typename BasicJsonType::number_integer_t number_integer_t
ptrdiff_t difference_type
std::random_access_iterator_tag iterator_category
typename It::iterator_category iterator_category
typename It::difference_type difference_type
typename It::value_type value_type
typename It::reference reference
typename It::pointer pointer
nonesuch(nonesuch const &&)=delete
void operator=(nonesuch &&)=delete
void operator=(nonesuch const &)=delete
nonesuch(nonesuch const &)=delete
abstract output adapter interface
output_adapter_protocol(const output_adapter_protocol &)=default
virtual ~output_adapter_protocol()=default
virtual void write_character(CharType c)=0
output_adapter_protocol(output_adapter_protocol &&) noexcept=default
output_adapter_protocol()=default
virtual void write_characters(const CharType *s, std::size_t length)=0
struct to capture the start position of the current token
std::size_t chars_read_current_line
the number of characters read in the current line
std::size_t lines_read
the number of lines read
std::size_t chars_read_total
the total number of characters read
static JSON_INLINE_VARIABLE constexpr T value
auto operator()(BasicJsonType &j, T &&val) const noexcept(noexcept(to_json(j, std::forward< T >(val)))) -> decltype(to_json(j, std::forward< T >(val)), void())
integer_sequence< T, Ints...,(Ints+SeqSize)... > type
integer_sequence< T, Ints...,(Ints+SeqSize)..., 2 *SeqSize > type
integer_sequence< T > type
typename Extend< typename Gen< T, N/2 >::type, N/2, N % 2 >::type type
static constexpr bool test(T val)
static constexpr bool test(T)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
static constexpr bool test(T val)
virtual bool binary(binary_t &val)=0
a binary value was read
virtual bool number_float(number_float_t val, const string_t &s)=0
a floating-point number was read
virtual bool number_unsigned(number_unsigned_t val)=0
an unsigned integer number was read
virtual bool key(string_t &val)=0
an object key was read
virtual bool string(string_t &val)=0
a string value was read
virtual bool number_integer(number_integer_t val)=0
an integer number was read
virtual bool start_object(std::size_t elements)=0
the beginning of an object was read
typename BasicJsonType::number_integer_t number_integer_t
typename BasicJsonType::string_t string_t
virtual bool end_array()=0
the end of an array was read
json_sax(const json_sax &)=default
virtual bool boolean(bool val)=0
a boolean value was read
virtual bool end_object()=0
the end of an object was read
typename BasicJsonType::number_float_t number_float_t
virtual bool null()=0
a null value was read
typename BasicJsonType::number_unsigned_t number_unsigned_t
json_sax(json_sax &&) noexcept=default
typename BasicJsonType::binary_t binary_t
virtual bool parse_error(std::size_t position, const std::string &last_token, const detail::exception &ex)=0
a parse error occurred
virtual bool start_array(std::size_t elements)=0
the beginning of an array was read
a minimal map-like container that preserves insertion order
std::vector< std::pair< const Key, T >, Allocator > Container
std::pair< iterator, bool > insert(value_type &&value)
typename Container::value_type value_type
std::equal_to< Key > key_compare
iterator erase(iterator pos)
ordered_map(const Allocator &alloc) noexcept(noexcept(Container(alloc)))
T & operator[](KeyType &&key)
typename Container::iterator iterator
const T & at(KeyType &&key) const
typename std::enable_if< std::is_convertible< typename std::iterator_traits< InputIt >::iterator_category, std::input_iterator_tag >::value >::type require_input_iter
const T & operator[](KeyType &&key) const
iterator find(const key_type &key)
iterator erase(iterator first, iterator last)
const T & at(const key_type &key) const
const_iterator find(const key_type &key) const
T & operator[](const key_type &key)
size_type erase(KeyType &&key)
typename Container::size_type size_type
ordered_map() noexcept(noexcept(Container()))
void insert(InputIt first, InputIt last)
size_type count(const key_type &key) const
std::pair< iterator, bool > emplace(KeyType &&key, T &&t)
size_type erase(const key_type &key)
ordered_map(std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
std::pair< iterator, bool > insert(const value_type &value)
size_type count(KeyType &&key) const
ordered_map(It first, It last, const Allocator &alloc=Allocator())
const T & operator[](const key_type &key) const
iterator find(KeyType &&key)
T & at(const key_type &key)
typename Container::const_iterator const_iterator
std::pair< iterator, bool > emplace(const key_type &key, T &&t)
std::size_t operator()(const nlohmann::NLOHMANN_BASIC_JSON_TPL &j) const
bool operator()(::nlohmann::detail::value_t lhs, ::nlohmann::detail::value_t rhs) const noexcept
compare two value_t enum values
#define JSON_HEDLEY_DIAGNOSTIC_PUSH
#define JSON_INLINE_VARIABLE
#define NLOHMANN_JSON_NAMESPACE_END
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name)
#define NLOHMANN_JSON_NAMESPACE_BEGIN
#define JSON_HEDLEY_DIAGNOSTIC_POP
#define NLOHMANN_BASIC_JSON_TPL_DECLARATION
#define JSON_HEDLEY_NON_NULL(...)
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define JSON_THROW(exception)
#define NLOHMANN_BASIC_JSON_TPL
#define JSON_HEDLEY_UNLIKELY(expr)
#define NLOHMANN_JSON_NAMESPACE_END
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
#define NLOHMANN_JSON_NAMESPACE_BEGIN
basic_json<> json
default specialization
#define JSON_HEDLEY_DEPRECATED_FOR(since, replacement)
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept